use quoted id of single AR::Base objects in predicates

This commit is contained in:
Aaron Patterson 2010-11-15 14:35:28 -08:00
parent e4591489d1
commit dcdfc84f55
2 changed files with 8 additions and 0 deletions

@ -25,6 +25,8 @@ def self.build_from_hash(engine, attributes, default_table)
attribute.in(values)
when Range, Arel::Relation
attribute.in(value)
when ActiveRecord::Base
attribute.eq(value.quoted_id)
else
attribute.eq(value)
end

@ -426,6 +426,12 @@ def test_find_in_empty_array
assert_blank authors.all
end
def test_where_with_ar_object
author = Author.first
authors = Author.scoped.where(:id => author)
assert_equal 1, authors.all.length
end
def test_exists
davids = Author.where(:name => 'David')
assert davids.exists?