1
0
Fork 0
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:
Yves Senn 2014-05-08 13:03:05 +02:00
parent 33fcdffff2
commit 83e0544204

View file

@ -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|