aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-01-30 12:21:52 -0500
committerRafael França <rafaelmfranca@gmail.com>2016-01-30 12:21:52 -0500
commita59212709c1daddf1c3703198cc3e45fd5226baf (patch)
tree4d008ee5a3898800de94de05d5caa66966b2d87c /activerecord/test
parent33848384f37b0acefc025ec72fc7896b3a3fdf88 (diff)
parent444c4d05fea817fcad991e79fa128b640e2e4ff1 (diff)
downloadrails-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/test')
-rw-r--r--activerecord/test/cases/primary_keys_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 8ce2b813bf..155210cce9 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -260,6 +260,13 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
assert_equal ["region", "code"], @connection.primary_keys("barcodes")
end
+ def test_primary_key_issues_warning
+ warning = capture(:stderr) do
+ @connection.primary_key("barcodes")
+ end
+ assert_match(/WARNING: Rails does not support composite primary key\./, warning)
+ end
+
def test_collectly_dump_composite_primary_key
schema = dump_table_schema "barcodes"
assert_match %r{create_table "barcodes", primary_key: \["region", "code"\]}, schema