aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder
diff options
context:
space:
mode:
authorchopraanmol1 <chopraanmol1@gmail.com>2017-08-08 03:23:45 +0530
committerchopraanmol1 <chopraanmol1@gmail.com>2017-08-08 03:23:45 +0530
commit7919d5ca7b11107671a72fa0cfd2adc139954e4e (patch)
treeddeabe7cbc98ed19384f9374e7b35f2b53f04cae /activerecord/lib/active_record/relation/predicate_builder
parentdf94b863c2ff8f1bcf12e36ed8fc1419292668e7 (diff)
downloadrails-7919d5ca7b11107671a72fa0cfd2adc139954e4e.tar.gz
rails-7919d5ca7b11107671a72fa0cfd2adc139954e4e.tar.bz2
rails-7919d5ca7b11107671a72fa0cfd2adc139954e4e.zip
Currently if relation object are passed to where condition for has one or has many association wrong set of primary key and foreign key are selected.
Changed code to use 'join' primary key and foreign key over 'association' primary key and foreign key.
Diffstat (limited to 'activerecord/lib/active_record/relation/predicate_builder')
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb b/activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb
index e64d9fdf2a..27efd49622 100644
--- a/activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb
@@ -9,7 +9,7 @@ module ActiveRecord
end
def queries
- [associated_table.association_foreign_key.to_s => ids]
+ [associated_table.association_join_fk.to_s => ids]
end
# TODO Change this to private once we've dropped Ruby 2.2 support.
@@ -30,7 +30,7 @@ module ActiveRecord
end
def primary_key
- associated_table.association_primary_key
+ associated_table.association_join_keys.key
end
def convert_to_id(value)