aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJosh Goodall <inopinatus@inopinatus.org>2019-07-17 15:18:54 +1000
committerJosh Goodall <inopinatus@inopinatus.org>2019-07-17 16:11:57 +1000
commitb19150448bcf65362c34b5a741ce162cd2b79216 (patch)
tree19eac18ee91b8ac284163b79df74af5d25c7d22b /activerecord/lib
parent32e5f9049c3ef626c9ba7b643c06b09b1ca8f6c1 (diff)
downloadrails-b19150448bcf65362c34b5a741ce162cd2b79216.tar.gz
rails-b19150448bcf65362c34b5a741ce162cd2b79216.tar.bz2
rails-b19150448bcf65362c34b5a741ce162cd2b79216.zip
Support beginless ranges in hash conditions.
Ruby 2.7 introduces beginless ranges (..value and ...value) and as with endless ranges we can turn these into inequalities, enabling expressions such as Order.where(created_at: ..1.year.ago) User.where(karma: ...0)
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/arel/predications.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/arel/predications.rb b/activerecord/lib/arel/predications.rb
index dece478615..895d394363 100644
--- a/activerecord/lib/arel/predications.rb
+++ b/activerecord/lib/arel/predications.rb
@@ -37,7 +37,7 @@ module Arel # :nodoc: all
def between(other)
if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1
self.in([])
- elsif open_ended?(other.begin)
+ elsif other.begin.nil? || open_ended?(other.begin)
if other.end.nil? || open_ended?(other.end)
not_in([])
elsif other.exclude_end?
@@ -85,7 +85,7 @@ Passing a range to `#in` is deprecated. Call `#between`, instead.
def not_between(other)
if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1
not_in([])
- elsif open_ended?(other.begin)
+ elsif other.begin.nil? || open_ended?(other.begin)
if other.end.nil? || open_ended?(other.end)
self.in([])
elsif other.exclude_end?