Skip to content

Commit

Permalink
Checking for null values before converting to boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 4, 2011
1 parent de6eda9 commit 665e560
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -238,7 +238,7 @@ function fetchResult() {
foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta;
$resultRow[$table][$column] = $row[$col];
if ($type == 'boolean') {
if ($type == 'boolean' && !is_null($row[$col])) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo/dbo_postgres.php
Expand Up @@ -707,7 +707,7 @@ function fetchResult() {

switch ($type) {
case 'bool':
$resultRow[$table][$column] = $this->boolean($row[$index]);
$resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]);
break;
case 'binary':
case 'bytea':
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo/dbo_sqlite.php
Expand Up @@ -336,7 +336,7 @@ function fetchResult() {
foreach ($this->map as $col => $meta) {
list($table, $column, $tpye) = $meta;
$resultRow[$table][$column] = $row[$col];
if ($type === 'boolean') {
if ($type == 'boolean' && !is_null($row[$col])) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
}
}
Expand Down

0 comments on commit 665e560

Please sign in to comment.