mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
test, regression test for unparsable PostgreSQL defaults.
This test was inspired by #14866. That PR would break this functionality and we should make sure we notice that in the future.
This commit is contained in:
parent
33fcdffff2
commit
83e0544204
1 changed files with 17 additions and 0 deletions
|
@ -396,6 +396,23 @@ module ActiveRecord
|
|||
reset_connection
|
||||
end
|
||||
|
||||
def test_unparsed_defaults_are_at_least_set_when_saving
|
||||
with_example_table "id SERIAL PRIMARY KEY, number INTEGER NOT NULL DEFAULT (4 + 4) * 2 / 4" do
|
||||
number_klass = Class.new(ActiveRecord::Base) do
|
||||
self.table_name = 'ex'
|
||||
end
|
||||
column = number_klass.columns_hash["number"]
|
||||
assert_nil column.default
|
||||
assert_nil column.default_function
|
||||
|
||||
first_number = number_klass.new
|
||||
assert_nil first_number.number
|
||||
|
||||
first_number.save!
|
||||
assert_equal 4, first_number.reload.number
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def insert(ctx, data)
|
||||
binds = data.map { |name, value|
|
||||
|
|
Loading…
Reference in a new issue