On Thursday, July 2, 2015 at 4:17:12 AM UTC-7, Janko Marohnić wrote: > > Jeremy, what do you mean by "unbounded ranges are not supported by Ruby"? > Because you can create these objects, and still obtain the #begin/#end > information. It would be cool if Sequel could detect a Ruby infinity and > make an unbounded range on that end, would that be doable? >
I mean that you cannot create a ruby Range object that is unbounded on either end. You can sort of get it to work for numeric ranges by using Float::INFINITY, but it doesn't work for time ranges or date ranges with unbounded beginnings: (Date.today..Float::INFINITY) # works ((-Float::INFINITY)..(Date.today)) # ArgumentError: bad value for range (Date.today..(Date::Infinity)) # ArgumentError: bad value for range (Date::Infinity...(Date.today)) # ArgumentError: bad value for range (Time.now..Float::INFINITY) # ArgumentError: bad value for range ((-Float::INFINITY)...(Time.now)) # ArgumentError: bad value for range While I could change Sequel to some of these unbounded range types with ruby ranges, it would then have inconsistent behavior for the various range types, and nobody has asked for native unbounded range support for numeric ranges (most range usage in PostgreSQL seems to deal with dates and times). I think the best solution here would be to send a patch to ruby to add support for infinite date/time objects. Because of how ruby ranges work, you need behavior such that Date.today <=> infinite_object and Time.now <=> infinite_object do not return nil. However, you'd also need to figure out correct behavior for places where the infinity object could be used in place of a Date or Time instance. 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.
