From 3ff5bfa829573842b0277f26f74eaa2f8c7a0d95 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 13 Mar 2008 03:06:14 +0000 Subject: [PATCH] Fixing default value for float columns in Postgres, fixes #3963 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6564 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo/dbo_firebird.php | 3 +-- cake/libs/model/datasources/dbo/dbo_postgres.php | 8 +------- .../libs/model/datasources/dbo/dbo_postgres.test.php | 7 +++++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_firebird.php b/cake/libs/model/datasources/dbo/dbo_firebird.php index 5f5fd9ab8..405b943a1 100644 --- a/cake/libs/model/datasources/dbo/dbo_firebird.php +++ b/cake/libs/model/datasources/dbo/dbo_firebird.php @@ -147,10 +147,9 @@ class DboFirebird extends DboSource { /** * Returns a row from given resultset as an array . * - * @param boolean $assoc Associative array only, or both? * @return array The fetched row as an array */ - function fetchRow($assoc = false) { + function fetchRow() { if (is_resource($this->_result)) { $this->resultSet($this->_result); $resultRow = $this->fetchResult(); diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index a6d389dcc..586a677b4 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -232,12 +232,7 @@ class DboPostgres extends DboSource { switch($column) { case 'inet': - if (!strlen($data)) { - return 'DEFAULT'; - } else { - $data = pg_escape_string($data); - } - break; + case 'float': case 'integer': if ($data === '') { return 'DEFAULT'; @@ -247,7 +242,6 @@ class DboPostgres extends DboSource { break; case 'binary': $data = pg_escape_bytea($data); - break; case 'boolean': default: diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 832f4fad4..72431a1de 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -193,6 +193,13 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->db->column('time without time zone'), 'time'); $this->assertEqual($this->db->column('timestamp without time zone'), 'datetime'); } + + function testValueQuoting() { + $this->assertEqual($this->db->value('0', 'integer'), "'0'"); + $this->assertEqual($this->db->value('', 'integer'), "DEFAULT"); + $this->assertEqual($this->db->value('', 'float'), "DEFAULT"); + $this->assertEqual($this->db->value('0.0', 'float'), "'0.0'"); + } } ?> \ No newline at end of file