diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-19 15:31:56 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-19 15:31:56 -0800 |
commit | 2df891dccdcfbdfb176c55297589712ac379f87d (patch) | |
tree | 0d2505faeaa910c2ef84ebcd70f45ab5d62bed99 /activerecord/lib/active_record | |
parent | e0c6156c693efffd8009a116a96f7ff631e4db47 (diff) | |
download | rails-2df891dccdcfbdfb176c55297589712ac379f87d.tar.gz rails-2df891dccdcfbdfb176c55297589712ac379f87d.tar.bz2 rails-2df891dccdcfbdfb176c55297589712ac379f87d.zip |
eliminate warnings about multiple primary keys on habtm join tables
habtm join tables commonly have two id columns and it's OK to make those
two id columns a primary key. This commit eliminates the warnings for
join tables that have this setup.
ManageIQ/manageiq#6713
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb index b888148841..5fbd79d118 100644 --- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb +++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb @@ -76,6 +76,9 @@ module ActiveRecord::Associations::Builder # :nodoc: left_model.retrieve_connection end + def self.primary_key + false + end } join_model.name = "HABTM_#{association_name.to_s.camelize}" diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb index 6aa264d766..6f2e03b370 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb @@ -118,7 +118,7 @@ module ActiveRecord alias :exec_update :exec_delete def sql_for_insert(sql, pk, id_value, sequence_name, binds) # :nodoc: - unless pk + if pk.nil? # Extract the table from the insert sql. Yuck. table_ref = extract_table_ref_from_insert_sql(sql) pk = primary_key(table_ref) if table_ref |