aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/primary_keys_test.rb
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-07-01 21:12:49 -0300
committerGitHub <noreply@github.com>2016-07-01 21:12:49 -0300
commit71acc3bd0100ba2ba32b8fe529dc3ea29b629126 (patch)
tree5132309391dbf4c1757c6d1c7f933ab6056cd714 /activerecord/test/cases/primary_keys_test.rb
parent173bf3506d99c0767a41d30fbe4d306201369194 (diff)
parent5d3a0b14c0439beab8e3af946dec88fddc07f896 (diff)
downloadrails-71acc3bd0100ba2ba32b8fe529dc3ea29b629126.tar.gz
rails-71acc3bd0100ba2ba32b8fe529dc3ea29b629126.tar.bz2
rails-71acc3bd0100ba2ba32b8fe529dc3ea29b629126.zip
Merge pull request #25620 from kamipo/create_without_primary_key
Pass `pk: false` to `connection.insert` explicitly if do not have a primary key
Diffstat (limited to 'activerecord/test/cases/primary_keys_test.rb')
-rw-r--r--activerecord/test/cases/primary_keys_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 6c8532cf00..4267ad4a24 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -174,6 +174,14 @@ class PrimaryKeysTest < ActiveRecord::TestCase
assert_equal '2', dashboard.id
end
+ def test_create_without_primary_key_no_extra_query
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = 'dashboards'
+ end
+ klass.create! # warmup schema cache
+ assert_queries(3, ignore_none: true) { klass.create! }
+ end
+
if current_adapter?(:PostgreSQLAdapter)
def test_serial_with_quoted_sequence_name
column = MixedCaseMonkey.columns_hash[MixedCaseMonkey.primary_key]