Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamps are not type casted #203

Closed
ged opened this issue Jan 26, 2015 · 4 comments
Closed

Timestamps are not type casted #203

ged opened this issue Jan 26, 2015 · 4 comments

Comments

@ged
Copy link
Owner

ged commented Jan 26, 2015

Original report by Victor (Bitbucket: victor987, GitHub: victor987).


According to the example given in https://bitbucket.org/ged/ruby-pg/raw/default/README.rdoc

#!ruby

conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
# ... this works for result value mapping:
conn.exec("select 1, now(), '{2,3}'::int[]").values
# => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]

Does not work for me:

#!ruby

conn = PG::Connection.new
conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
conn.exec("select 1, now(), '{2,3}'::int[]").values
# => [[1, "2015-01-26 17:26:42.691511-04:30", [2, 3]]]

The timestamp is still a String

#!ruby

RUBY_VERSION
# => "2.1.5" 
PG::VERSION
# => "0.18.1" 

With PostgreSQL 9.4

@ged
Copy link
Owner Author

ged commented Jan 27, 2015

Original comment by Lars Kanis (Bitbucket: larskanis, GitHub: larskanis).


This is a bug. The current timestamp decoder does not handle :15, :30 or :45 timezones (I wasn't able to test the gem in Afghanistan so far). I'll fix this.

@ged
Copy link
Owner Author

ged commented Jan 27, 2015

Original comment by Lars Kanis (Bitbucket: larskanis, GitHub: larskanis).


Fixed by 332258052

@ged ged closed this as completed Jan 27, 2015
@ged
Copy link
Owner Author

ged commented Jan 27, 2015

Original comment by Victor (Bitbucket: victor987, GitHub: victor987).


Thank you. Not Afghanistan (+04:30) but Venezuela (-04:30).
You should be aware that some old time zones are even more exotic:

#!sql

SET TIME ZONE 'Europe/Dublin'; -- Was UTC−00:25:21 until 1916
SELECT '1900-01-01'::timestamptz;
-- "1900-01-01 00:00:00-00:25:21"

I'll test the next release.

@ged
Copy link
Owner Author

ged commented Jan 27, 2015

Original comment by Lars Kanis (Bitbucket: larskanis, GitHub: larskanis).


Thanks for the hint. I'll add this, too.

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

No branches or pull requests

1 participant