1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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]]
```
This commit is contained in:
Ryuta Kamizono 2017-06-28 21:59:28 +09:00
parent d766b64b7e
commit bf3f201000
2 changed files with 2 additions and 5 deletions

View file

@ -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

View file

@ -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