Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Boolean ’t’/‘f’ strings need to be coerced to int properly. #93

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion code/PostgreSQLQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public function nextRecord()
$record[$k] = $v;
$type = pg_field_type($this->handle, $i);
if (isset(self::$typeMapping[$type])) {
settype($record[$k], self::$typeMapping[$type]);
if ($type === 'bool' && $record[$k] === 't') {
$record[$k] = 1;
} else {
settype($record[$k], self::$typeMapping[$type]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this implicitly handle f values?

Copy link
Member Author

@sminnee sminnee Jan 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah $d = 'f'; settype($d, 'int'); return $d returns 0. Is it too hacky to rely on that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment? I was just curious

}
}
}

Expand Down