postgres: Return 0 if a timestamp looks like the default timestamp

The PostgreSQL IDO schema sets the default value for timestamps with time zone
to the epoch time w/o giving the time zone +00. Thus default timestamps are always
wrong when using a time zone other than 'UTC'.

refs #7919
This commit is contained in:
Eric Lippmann 2015-01-16 17:05:50 +01:00
parent dae3ccd90c
commit 09d5ec6b7a

View File

@ -323,6 +323,11 @@ abstract class IdoQuery extends DbQuery
foreach ($columns as $key => & $value) {
$value = preg_replace('/ COLLATE .+$/', '', $value);
$value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value);
$value = preg_replace(
'/(UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\)))/i',
'CASE WHEN ($1 = EXTRACT(TIMEZONE FROM NOW()) * -1) THEN 0 ELSE $1 END',
$value
);
}
}
}