Skip to content

Commit

Permalink
Changing a bit how postgres driver treats booleans so it correcty cas…
Browse files Browse the repository at this point in the history
…ts them
  • Loading branch information
lorenzo committed Jan 2, 2011
1 parent da152e0 commit 1d530db
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cake/libs/model/datasources/dbo/dbo_postgres.php
Expand Up @@ -162,7 +162,6 @@ function listSources($data = null) {
$result = $this->_execute($sql, array($schema));

if (!$result) {
$result->closeCursor();
return array();
} else {
$tables = array();
Expand Down Expand Up @@ -248,7 +247,9 @@ function describe($model) {
$this->_sequenceMap[$table][$model->primaryKey] = $model->sequence;
}

$cols->closeCursor();
if ($cols) {
$cols->closeCursor();
}
return $fields;
}

Expand Down Expand Up @@ -706,7 +707,7 @@ function fetchResult() {

switch ($type) {
case 'bool':
$resultRow[$table][$column] = $this->boolean($row[$index], false);
$resultRow[$table][$column] = $this->boolean($row[$index]);
break;
case 'binary':
case 'bytea':
Expand All @@ -731,7 +732,7 @@ function fetchResult() {
* @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
*/
function boolean($data, $quote = true) {
function boolean($data, $quote = false) {
switch (true) {
case ($data === true || $data === false):
$result = $data;
Expand All @@ -753,7 +754,7 @@ function boolean($data, $quote = true) {
if ($quote) {
return ($result) ? 'TRUE' : 'FALSE';
}
return (int) $result;
return (bool) $result;
}

/**
Expand Down

0 comments on commit 1d530db

Please sign in to comment.