mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
use quoted id of single AR::Base objects in predicates
This commit is contained in:
@@ -25,6 +25,8 @@ module ActiveRecord
|
||||
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 @@ class RelationTest < ActiveRecord::TestCase
|
||||
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?
|
||||
|
||||
Reference in New Issue
Block a user