diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-01-30 12:21:52 -0500 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-01-30 12:21:52 -0500 |
commit | a59212709c1daddf1c3703198cc3e45fd5226baf (patch) | |
tree | 4d008ee5a3898800de94de05d5caa66966b2d87c /activerecord/lib | |
parent | 33848384f37b0acefc025ec72fc7896b3a3fdf88 (diff) | |
parent | 444c4d05fea817fcad991e79fa128b640e2e4ff1 (diff) | |
download | rails-a59212709c1daddf1c3703198cc3e45fd5226baf.tar.gz rails-a59212709c1daddf1c3703198cc3e45fd5226baf.tar.bz2 rails-a59212709c1daddf1c3703198cc3e45fd5226baf.zip |
Merge pull request #23345 from yui-knk/warning_when_composite_primary_key_is_detected
Warn if `AR.primary_key` is called for a table who has composite prim…
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index c00b629632..8db7f9172f 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -125,6 +125,12 @@ module ActiveRecord # Returns just a table's primary key def primary_key(table_name) pks = primary_keys(table_name) + warn <<-WARNING.strip_heredoc if pks.count > 1 + WARNING: Rails does not support composite primary key. + + #{table_name} has composite primary key. Composite primary key is ignored. + WARNING + pks.first if pks.one? end |