mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Do not send id for quoting twice if the primary key is string.
[#6022 state:resolved]
This commit is contained in:
committed by
Aaron Patterson
parent
0456feab11
commit
d33dcba72d
@@ -26,7 +26,8 @@ module ActiveRecord
|
||||
when Range, Arel::Relation
|
||||
attribute.in(value)
|
||||
when ActiveRecord::Base
|
||||
attribute.eq(value.quoted_id)
|
||||
sanitized_id = attribute.class == Arel::Attributes::String ? value.id : value.quoted_id
|
||||
attribute.eq(sanitized_id)
|
||||
when Class
|
||||
# FIXME: I think we need to deprecate this behavior
|
||||
attribute.eq(value.name)
|
||||
|
||||
@@ -14,11 +14,18 @@ require 'models/bird'
|
||||
require 'models/car'
|
||||
require 'models/engine'
|
||||
require 'models/tyre'
|
||||
require 'models/minivan'
|
||||
|
||||
|
||||
class RelationTest < ActiveRecord::TestCase
|
||||
fixtures :authors, :topics, :entrants, :developers, :companies, :developers_projects, :accounts, :categories, :categorizations, :posts, :comments,
|
||||
:tags, :taggings, :cars
|
||||
:tags, :taggings, :cars, :minivans
|
||||
|
||||
def test_do_not_double_quote_string_id
|
||||
van = Minivan.last
|
||||
assert van
|
||||
assert_equal van.id, Minivan.where(:minivan_id => van).to_a.first.minivan_id
|
||||
end
|
||||
|
||||
def test_bind_values
|
||||
relation = Post.scoped
|
||||
|
||||
Reference in New Issue
Block a user