geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Update pg to 2.5.x #92

Closed ben-ng closed 11 years ago

ben-ng commented 11 years ago

Update: now mergable.

One oddity that arises from this change is that datetimes may not survive round trips.

The reason is because when datetimes are saved, they're saved in UTC. When they're reified, the date object has the correct time, but in the wrong timezone. So the tests fail. Sometimes. I've managed to get them failing with Postgres.app on Mac OSX, but they'll pass on Travis' machines.

I can't understand what is going on, was hoping @mde had some insight from writing timezone.js

Here is the relevant code in the pg module: https://github.com/brianc/node-postgres/blob/84af374ab7024f13815686c6b1dbeb07e599a6b9/lib/types/textParsers.js#L37.

ben-ng commented 11 years ago

Okay, 729dcbf99033105269b2965f8f669091239f8d6a should resolve the iffiness about datetime roundtrips.

It looks like geddy does take care to store datetimes in UTC already, so the simple solution was to fetch datetimes in UTC too.

The reason why updating to the latest pg resulted in this issue is because they now check for a timezone in the fetched value, and if none is present it'll use the user's timezone. Fetching datetimes in UTC makes pg use the old logic in 0.9.x.

ben-ng commented 11 years ago

Closing this as it's been handled in master