Changing a bit how postgres driver treats booleans so it correcty casts them

This commit is contained in:
José Lorenzo Rodríguez 2011-01-01 22:09:22 -04:30
parent da152e0e82
commit 1d530db39b

View file

@ -162,7 +162,6 @@ class DboPostgres extends DboSource {
$result = $this->_execute($sql, array($schema)); $result = $this->_execute($sql, array($schema));
if (!$result) { if (!$result) {
$result->closeCursor();
return array(); return array();
} else { } else {
$tables = array(); $tables = array();
@ -248,7 +247,9 @@ class DboPostgres extends DboSource {
$this->_sequenceMap[$table][$model->primaryKey] = $model->sequence; $this->_sequenceMap[$table][$model->primaryKey] = $model->sequence;
} }
if ($cols) {
$cols->closeCursor(); $cols->closeCursor();
}
return $fields; return $fields;
} }
@ -706,7 +707,7 @@ class DboPostgres extends DboSource {
switch ($type) { switch ($type) {
case 'bool': case 'bool':
$resultRow[$table][$column] = $this->boolean($row[$index], false); $resultRow[$table][$column] = $this->boolean($row[$index]);
break; break;
case 'binary': case 'binary':
case 'bytea': case 'bytea':
@ -731,7 +732,7 @@ class DboPostgres extends DboSource {
* @param boolean $quote true to quote a boolean to be used in a query, flase to return the boolean value * @param boolean $quote true to quote a boolean to be used in a query, flase to return the boolean value
* @return boolean Converted boolean value * @return boolean Converted boolean value
*/ */
function boolean($data, $quote = true) { function boolean($data, $quote = false) {
switch (true) { switch (true) {
case ($data === true || $data === false): case ($data === true || $data === false):
$result = $data; $result = $data;
@ -753,7 +754,7 @@ class DboPostgres extends DboSource {
if ($quote) { if ($quote) {
return ($result) ? 'TRUE' : 'FALSE'; return ($result) ? 'TRUE' : 'FALSE';
} }
return (int) $result; return (bool) $result;
} }
/** /**