diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-28 21:59:28 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-28 21:59:28 +0900 |
commit | bf3f2010003326a42d86a88425e3c66242c2f2f1 (patch) | |
tree | 6f01a6629628e16d195c6516b3df2be7e2e5ccb2 /activerecord | |
parent | d766b64b7e137955b7c7dbab51d2b6e525de47c1 (diff) | |
download | rails-bf3f2010003326a42d86a88425e3c66242c2f2f1.tar.gz rails-bf3f2010003326a42d86a88425e3c66242c2f2f1.tar.bz2 rails-bf3f2010003326a42d86a88425e3c66242c2f2f1.zip |
Fix `ids_reader` to respect case sensitive primary key
```ruby
car = Car.create!(name: "Tofaş")
# Before
car.bulb_ids # => SELECT "bulbs".ID FROM "bulbs" WHERE "bulbs"."name" = $1 AND "bulbs"."car_id" = $2 [["name", "defaulty"], ["car_id", 3]]
# After
car.bulb_ids # => SELECT "bulbs"."ID" FROM "bulbs" WHERE "bulbs"."name" = $1 AND "bulbs"."car_id" = $2 [["name", "defaulty"], ["car_id", 3]]
```
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 5 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 2 |
2 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 0cb17b47e8..583ee11907 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -44,10 +44,7 @@ module ActiveRecord if loaded? target.pluck(reflection.association_primary_key) else - @association_ids ||= ( - column = "#{reflection.quoted_table_name}.#{reflection.association_primary_key}" - scope.pluck(column) - ) + @association_ids ||= scope.pluck(reflection.association_primary_key) end end diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index d7ceb6d4ef..f534e9c00e 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -107,7 +107,7 @@ ActiveRecord::Schema.define do t.boolean :has_fun, null: false, default: false end - create_table :bulbs, force: true do |t| + create_table :bulbs, primary_key: "ID", force: true do |t| t.integer :car_id t.string :name t.boolean :frickinawesome, default: false |