db2 driver updates
This commit is contained in:
@@ -25,28 +25,47 @@ class Db2Connection extends Connection
|
||||
$fetchUsing
|
||||
);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (! is_object($row)) {
|
||||
foreach ($rows as &$row) {
|
||||
if (! is_object($row) && ! is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($row as $key => $value) {
|
||||
if ($value === Db2QueryGrammar::NULL_TIMESTAMP_SENTINEL) {
|
||||
$row->{$key} = null;
|
||||
$values = (array) $row;
|
||||
$result = [];
|
||||
$previousColumn = null;
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
if (
|
||||
is_string($key) &&
|
||||
preg_match('/^__db2_null_flag_[0-9]+$/i', $key)
|
||||
) {
|
||||
if ($previousColumn === null) {
|
||||
throw new \RuntimeException(
|
||||
'Db2 NULL indicator has no preceding column.'
|
||||
);
|
||||
}
|
||||
|
||||
if ((string) $value === '1') {
|
||||
$result[$previousColumn] = null;
|
||||
} elseif ((string) $value !== '0') {
|
||||
throw new \RuntimeException(
|
||||
'Unexpected Db2 NULL indicator value.'
|
||||
);
|
||||
}
|
||||
|
||||
$previousColumn = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
in_array($key, [
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
], true)
|
||||
&& $value === Db2QueryGrammar::NULL_STRING_SENTINEL
|
||||
) {
|
||||
$row->{$key} = null;
|
||||
}
|
||||
$result[$key] = $value;
|
||||
$previousColumn = $key;
|
||||
}
|
||||
|
||||
$row = is_object($row)
|
||||
? (object) $result
|
||||
: $result;
|
||||
}
|
||||
unset($row);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user