提交 71acc3bd 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #25620 from kamipo/create_without_primary_key

Pass `pk: false` to `connection.insert` explicitly if do not have a primary key
......@@ -65,7 +65,7 @@ def insert(values) # :nodoc:
@klass.connection.insert(
im,
'SQL',
primary_key,
primary_key || false,
primary_key_value,
nil,
binds)
......
......@@ -174,6 +174,14 @@ def test_primary_key_update_with_custom_key_name
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]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册