On Tuesday, June 16, 2015 at 6:25:57 AM UTC-7, Andrew Burleson wrote:
>
> Jeremy,
>
> Following up on your suggestion to me in a different thread (I wanted this 
> question to have a better title for searching), I've been exploring the 
> pg_range extension and working on using tsrange.
>
> One issue: given a schema like this:
>
> create_table :order_states do
>   primary_key :id
>   column :timeframe, :tsrange, :index=>{:type=>:gist}
> end
>
> If I want to create a range that goes from now to the indefinite future, 
> it looks like Postgres wants an insert value like:
>
> [today, ‘infinity’)
>
> So, in Ruby I tried:
>
> os = OrderState.create(timeframe: (Date.today..Float::INFINITY))
>
> This fails with
>
> Sequel::InvalidValue: ArgumentError: no time information in "infinity"
>
> Also, I managed to write a record once with SQL strings, but when I try to 
> load that record I get the same error.
>
> So, what is the correct technique for doing using +/- infinity in 
> pg_ranges? I've googled a bunch and not been able to find docs for this.
>

Unbounded ranges are not supported by ruby, so you can't use ruby ranges to 
represent them. You have to create the PGRange object manually:

  Sequel::Postgres::PGRange.new(Date.today, nil)

As you can see here, you can use nil instead of some infinity object, since 
nil specifies no bound, and unbounded ranges are infinite ranges 
(http://www.postgresql.org/docs/9.4/static/rangetypes.html).

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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to