Postgresql adapter: fix handling of BC timestamps #6245

Merged
merged 1 commit into from Nov 21, 2012

Conversation

Projects
None yet
3 participants
Contributor

bogdan commented May 10, 2012

Ruby and Postgresql representation of BC(before christ) time stamps is different:

Ruby serializes it with negative number of years. Postgresql adds BC suffix instead.
This cause a bug.

This patch fixes datetime conversion in postgresql adapter to handle this edge case correctly.

If you know a better way of fixing it - please advice.

activerecord/test/cases/adapters/postgresql/timestamp_test.rb
@@ -27,4 +27,13 @@ def test_save_infinity_and_beyond
d = Developer.create!(:name => 'aaron', :updated_at => -1.0 / 0.0)
assert_equal(-1.0 / 0.0, d.updated_at)
end
+
+ def test_bc_timestamp
+ unless current_adapter?(:PostgreSQLAdapter)
@steveklabnik

steveklabnik Sep 16, 2012

Member

Is this actually needed? Since this is under the postgresql adapters test, won't it only be tested on postgresql?

@bogdan

bogdan Nov 3, 2012

Contributor

I saw this in the tests above in this file.
We can try to remove this, but I would address it to different pull or commit.

Member

steveklabnik commented Sep 16, 2012

This will need a rebase.

@bogdan bogdan closed this Nov 3, 2012

@bogdan bogdan reopened this Nov 3, 2012

Owner

rafaelfranca commented Nov 19, 2012

Hey @bogdan your fixes seems fine. We will need a CHANGELOG entry and remove these two extra commits.

Contributor

bogdan commented Nov 21, 2012

done

rafaelfranca added a commit that referenced this pull request Nov 21, 2012

Merge pull request #6245 from bogdan/bc_timestamp
Postgresql adapter: fix handling of BC timestamps

@rafaelfranca rafaelfranca merged commit 1c0e7ab into rails:master Nov 21, 2012

Owner

rafaelfranca commented Nov 21, 2012

❤️ 💚 💙 💛 💜

@bogdan bogdan deleted the bogdan:bc_timestamp branch May 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment