diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-01 01:00:18 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-01 01:00:18 +0530 |
commit | 783caae52f3c00975490cd40dc849f648c8fa9e1 (patch) | |
tree | 980436ddd73f8a2a8dc6c2e161c097dd3fce05c3 | |
parent | 93555c672e3edd5705eb381f2bf3d4f93cffa96f (diff) | |
download | rails-783caae52f3c00975490cd40dc849f648c8fa9e1.tar.gz rails-783caae52f3c00975490cd40dc849f648c8fa9e1.tar.bz2 rails-783caae52f3c00975490cd40dc849f648c8fa9e1.zip |
Use Arel::Attribute for pk conditions
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 7a1d6fc538..c3e5f27838 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -21,8 +21,8 @@ module ActiveRecord 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 @@ module ActiveRecord 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 @@ module ActiveRecord 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 |