class PostgresqlDataTypeTest
Public Instance Methods
setup()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 18 def setup @connection = ActiveRecord::Base.connection @connection.execute("INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')") @first_time = PostgresqlTime.find(1) @connection.execute("INSERT INTO postgresql_oids (id, obj_id) VALUES (1, 1234)") @first_oid = PostgresqlOid.find(1) end
test_data_type_of_oid_types()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 37 def test_data_type_of_oid_types assert_equal :oid, @first_oid.column_for_attribute(:obj_id).type end
test_data_type_of_time_types()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 32 def test_data_type_of_time_types assert_equal :interval, @first_time.column_for_attribute(:time_interval).type assert_equal :interval, @first_time.column_for_attribute(:scaled_time_interval).type end
test_oid_values()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 46 def test_oid_values assert_equal 1234, @first_oid.obj_id end
test_text_columns_are_limitless_the_upper_limit_is_one_GB()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 65 def test_text_columns_are_limitless_the_upper_limit_is_one_GB assert_equal "text", @connection.type_to_sql(:text, limit: 100_000) assert_raise ActiveRecord::ActiveRecordError do @connection.type_to_sql(:text, limit: 4294967295) end end
test_time_values()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 41 def test_time_values assert_equal "-1 years -2 days", @first_time.time_interval assert_equal "-21 days", @first_time.scaled_time_interval end
test_update_oid()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 57 def test_update_oid new_value = 567890 @first_oid.obj_id = new_value assert @first_oid.save assert @first_oid.reload assert_equal new_value, @first_oid.obj_id end
test_update_time()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/datatype_test.rb, line 50 def test_update_time @first_time.time_interval = "2 years 3 minutes" assert @first_time.save assert @first_time.reload assert_equal "2 years 00:03:00", @first_time.time_interval end