mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix serial?
with quoted sequence name
This commit is contained in:
parent
50999974e8
commit
684caf5503
2 changed files with 10 additions and 1 deletions
|
@ -8,7 +8,8 @@ module ActiveRecord
|
|||
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 @@ class PrimaryKeysTest < ActiveRecord::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue