Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Arel::Attribute for pk conditions

  • Loading branch information...
commit 783caae52f3c00975490cd40dc849f648c8fa9e1 1 parent 93555c6
@lifo lifo authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 activerecord/lib/active_record/relation/finder_methods.rb
View
8 activerecord/lib/active_record/relation/finder_methods.rb
@@ -21,8 +21,8 @@ def find(*ids, &block)
end
def exists?(id = nil)
- relation = select("#{@klass.quoted_table_name}.#{@klass.primary_key}").limit(1)
- relation = relation.where(@klass.primary_key => id) if id
+ relation = select(primary_key).limit(1)
+ relation = relation.where(primary_key.eq(id)) if id
relation.first ? true : false
end
@@ -78,7 +78,7 @@ def find_or_instantiator_by_attributes(match, attributes, *args)
end
def find_one(id)
- record = where(@klass.primary_key => id).first
+ record = where(primary_key.eq(id)).first
unless record
conditions = where_clause(', ')
@@ -90,7 +90,7 @@ def find_one(id)
end
def find_some(ids)
- result = where(@klass.primary_key => ids).all
+ result = where(primary_key.in(ids)).all
expected_size =
if @relation.taken && ids.size > @relation.taken
Please sign in to comment.
Something went wrong with that request. Please try again.