Float::INFINITY ranges in where() clause

This seems like such an obvious idea that I'm having trouble believing I'm the first to think of it. Why not take ranges containing Float::INFINITY and translate them to the appropriate greater than or less than comparisons? Example:

class Person    scope :voters, -> { where(born_on: (-Float::INFINITY..18.years.ago)) } end

This would generate something along the lines of "WHERE people.born_on <= '1995-02-19'".

A proof of concept implementation was easy to knock out:     https://github.com/tpope/rails/commit/b98545a930546854ddf401edfaad4a3a4860aeff

This seems like a intuitive, unobtrusive way to make some comparison operators available without dropping down to SQL. Tell me why I'm wrong.

You're wrong because you didn't add any tests. :wink:

Wanted to make sure I wasn't crazy before sorting those out. I'll take this as a vote of confidence.

Testing led me to ARel as the more natural destination:

https://github.com/tpope/arel/tree/infinity-ranges

Excellent. It seems legit. I wish there was a more elegant way than all the if / elsif, but I don't see it.

Send a PR and we can makeitso.

You mean like this?

case     when other.begin == -Float::INFINITY && other.end == Float::INFINITY then Nodes::NotIn.new self,     when other.end == Float::INFINITY then Nodes::GreaterThanOrEqual.new(self, other.begin)     when other.begin == -Float::INFINITY && other.exclude_end? then Nodes::LessThan.new(self, other.end)     when other.begin == -Float::INFINITY then Nodes::LessThanOrEqual.new(self, other.end)     when other.exclude_end?        ...