提交 684caf55 编写于 作者: R Ryuta Kamizono

Fix `serial?` with quoted sequence name

上级 50999974
......@@ -8,7 +8,8 @@ class PostgreSQLColumn < Column #:nodoc:
def serial?
return unless default_function
%r{\Anextval\('(?<table_name>.+)_#{name}_seq'::regclass\)\z} === default_function
table_name = @table_name || '(?<table_name>.+)'
%r{\Anextval\('"?#{table_name}_#{name}_seq"?'::regclass\)\z} === default_function
end
end
end
......
......@@ -175,6 +175,14 @@ def test_primary_key_update_with_custom_key_name
dashboard = Dashboard.first
assert_equal '2', dashboard.id
end
if current_adapter?(:PostgreSQLAdapter)
def test_serial_with_quoted_sequence_name
column = MixedCaseMonkey.columns_hash[MixedCaseMonkey.primary_key]
assert_equal "nextval('\"mixed_case_monkeys_monkeyID_seq\"'::regclass)", column.default_function
assert column.serial?
end
end
end
class PrimaryKeyWithNoConnectionTest < ActiveRecord::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册