aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/where_clause.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-28 14:04:26 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-28 14:35:03 -0700
commitff45b9e9f7c4ff0fb4fdab8beb539913b876d63b (patch)
tree1513baae2abecb8e0ce14fe21ae8563c876d25ab /activerecord/lib/active_record/relation/where_clause.rb
parentb0b37942d729b6bdcd2e3178eda7fa1de203b3d0 (diff)
downloadrails-ff45b9e9f7c4ff0fb4fdab8beb539913b876d63b.tar.gz
rails-ff45b9e9f7c4ff0fb4fdab8beb539913b876d63b.tar.bz2
rails-ff45b9e9f7c4ff0fb4fdab8beb539913b876d63b.zip
Bring the implementation of Relation#or up to speed
Diffstat (limited to 'activerecord/lib/active_record/relation/where_clause.rb')
-rw-r--r--activerecord/lib/active_record/relation/where_clause.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/where_clause.rb b/activerecord/lib/active_record/relation/where_clause.rb
index ae5667dfd6..ce307e4f0c 100644
--- a/activerecord/lib/active_record/relation/where_clause.rb
+++ b/activerecord/lib/active_record/relation/where_clause.rb
@@ -31,6 +31,19 @@ module ActiveRecord
)
end
+ def or(other)
+ if empty?
+ other
+ elsif other.empty?
+ self
+ else
+ WhereClause.new(
+ [ast.or(other.ast)],
+ binds + other.binds
+ )
+ end
+ end
+
def to_h(table_name = nil)
equalities = predicates.grep(Arel::Nodes::Equality)
if table_name