Feature #2840
closedDbo Postgres backend: Support WDateTime in TIMEStAMP WITH TIME ZONE columns
0%
Description
By default, the Dbo backend for Postgres creates TIMESTAMP columns to hold WDateTimes. However, legacy tables may include TIMESTAMP WITH TIME ZONE columns. For instance, Django creates datetime columns with this option.
Dbo will currently write WDateTime values to TIMESTAMP WITH TIME ZONE columns, but the values will be incorrect unless the client is configured with a UTC timezone. Postgres assumes the timestamp values are in localtime and will adjust them to UTC.
Dbo will read WDateTime values from TIMESTAMP WITH TIME ZONE columns, but silently ignores the timezone offset that Postgres appends --- if the offset is negative. If the timezone offset is not negative, a bad lexical cast is thrown.
I've attached a patch with some test cases to illustrate the issue. The tests dbo_test22a and dbo_test22b provide negative and positive timezone offsets, leaving the default TIMESTAMP column. They should succeed. The tests dbo_test22c and dbo_test22d, are analogous but alter the table to use TIMESTAMP WITH TIME ZONE columns. They should fail.
For your review, I've also included a patch to the Dbo backend for Postgres which seems to help in limited testing.
Files
Updated by Bruce Toll over 10 years ago
NOTE: Description and patch are based on github version 3.3.2-rc1-40-ge0e054f.
Updated by Koen Deforche over 10 years ago
- Status changed from New to InProgress
- Assignee set to Koen Deforche
- Target version set to 3.3.3
Updated by Koen Deforche over 10 years ago
- Status changed from InProgress to Resolved
Hey,
I've applied the patch. My postgres version did not support 'SET DATA' as syntax, I'm not sure why but it's optional anyway.
Regards,
koen
Updated by Bruce Toll over 10 years ago
Hey Koen,
Thanks for this. It looks like support for the 'SET DATA' syntax was added in 8.4.
Regards,
Bruce
Updated by Koen Deforche over 10 years ago
- Status changed from Resolved to Closed