diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-01-09 01:43:08 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-08-13 16:17:35 +0900 |
commit | b23e86967c4dfa5aa4f007291458c48dd39b179a (patch) | |
tree | bf35c7a8d0fc2eb722e67a9fb1291d81861f614c /railties/test | |
parent | e3962308e7947f3d99c70c192e2d1356d3420e1e (diff) | |
download | rails-b23e86967c4dfa5aa4f007291458c48dd39b179a.tar.gz rails-b23e86967c4dfa5aa4f007291458c48dd39b179a.tar.bz2 rails-b23e86967c4dfa5aa4f007291458c48dd39b179a.zip |
Fix `reflection.association_primary_key` for `has_many` associations
It is incorrect to treat `options[:primary_key]` as
`association_primary_key` if `has_many` associations because the
`:primary_key` means the column on the owner record, not on the
association record. It will break `ids_reader` and `ids_writer`.
```ruby
people(:david).essay_ids
# => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David'
```
Fixes #14439.
Diffstat (limited to 'railties/test')
0 files changed, 0 insertions, 0 deletions