diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-08 13:03:05 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-08 13:04:51 +0200 |
commit | 83e0544204a1b0125af15e1ea0e54aa30b2266ab (patch) | |
tree | 1327a5ea057bd302f1f573d8e411109cbe1b9daa /activerecord | |
parent | 33fcdffff285f43ba5f8787cbf193a1b7f9b582b (diff) | |
download | rails-83e0544204a1b0125af15e1ea0e54aa30b2266ab.tar.gz rails-83e0544204a1b0125af15e1ea0e54aa30b2266ab.tar.bz2 rails-83e0544204a1b0125af15e1ea0e54aa30b2266ab.zip |
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.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index b7791078db..49f5ec250f 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -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| |