Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do not send id for quoting twice if the primary key is string.

[#6022 state:resolved]
  • Loading branch information...
commit d67464a160bf2a5ef899a14cff93756aad374a6a 1 parent 890d005
Neeraj Singh neerajdotname authored tenderlove committed
3  activerecord/lib/active_record/relation/predicate_builder.rb
View
@@ -31,7 +31,8 @@ def build_from_hash(attributes, default_table)
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)
9 activerecord/test/cases/relations_test.rb
View
@@ -13,11 +13,18 @@
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,
- :taggings, :cars
+ :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_two_named_scopes_with_includes_should_not_drop_any_include
car = Car.incl_engines.incl_tyres.first
Please sign in to comment.
Something went wrong with that request. Please try again.