On Wednesday, May 4, 2016 at 3:15:39 PM UTC-7, Chris Riddoch wrote: > > Thanks Jeremy, that code gave me a good start on this. It almost works > when I have convert_infinite_timestamps set to :nil. I think all the > utility functions necessary are already in place so that I can make it > handle :string and :float, once I spend a bit more time reading this file > and a bit more of the pg extension support code. > > Now I'm just trying to figure out why the type conversions are giving me > Time objects instead of DateTime for the endpoints of the range. Most > places in my application where dates are involved use DateTime, with > 'timestamp with time zone' behind them. Even when I have > Sequel.datetime_class = DateTime, the PGRange is converting them to Time. > This would be fine, except that DateTime and Time aren't comparable with > each other with their <, >, etc. operators. > > Thanks for all your help with this. >
Can you explain why infinite timestamp support would matter? Timestamp ranges shouldn't use infinite timestamp values, they should just be unbounded on that end (http://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-INFINITE). I guess you could use infinite timestamp values in a range, but it's probably a bad idea. I'm not sure what problems you are having with DateTime, if you set Sequel.datetimeclass = DateTime, then the begin/end values of PGRange instances should be DateTime objects: DB.get(Sequel::Postgres::PGRange.new(Time.now, nil, :db_type=>'tsrange')).begin.class # INFO -- : (0.000362s) SELECT tsrange('2016-05-04 15:41:41.701081-0700',NULL,'[]') AS "v" LIMIT 1 # => Time Sequel.datetime_class = DateTime # => DateTime DB.get(Sequel::Postgres::PGRange.new(Time.now, nil, :db_type=>'tsrange')).begin.class # INFO -- : (0.000380s) SELECT tsrange('2016-05-04 15:41:51.065161-0700',NULL,'[]') AS "v" LIMIT 1 # => DateTime Could you post a self contained example showing the problem you are having? Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
