class ActiveRecord::ConnectionAdapters::TypeLookupTest

Public Instance Methods

test_bigint_limit() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 84
def test_bigint_limit
  cast_type = @connection.send(:type_map).lookup("bigint")
  if current_adapter?(:OracleAdapter)
    assert_equal 19, cast_type.limit
  else
    assert_equal 8, cast_type.limit
  end
end
test_binary_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 26
def test_binary_types
  assert_lookup_type :binary, "binary"
  assert_lookup_type :binary, "BINARY"
  assert_lookup_type :binary, "blob"
  assert_lookup_type :binary, "BLOB"
end
test_boolean_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 13
def test_boolean_types
  assert_lookup_type :boolean, "boolean"
  assert_lookup_type :boolean, "BOOLEAN"
end
test_date_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 40
def test_date_types
  assert_lookup_type :date, "date"
  assert_lookup_type :date, "DATE"
end
test_datetime_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 50
def test_datetime_types
  assert_lookup_type :datetime, "datetime"
  assert_lookup_type :datetime, "DATETIME"
  assert_lookup_type :datetime, "timestamp"
  assert_lookup_type :datetime, "TIMESTAMP"
end
test_decimal_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 57
def test_decimal_types
  assert_lookup_type :decimal, "decimal"
  assert_lookup_type :decimal, "decimal(2,8)"
  assert_lookup_type :decimal, "DECIMAL"
  assert_lookup_type :decimal, "numeric"
  assert_lookup_type :decimal, "numeric(2,8)"
  assert_lookup_type :decimal, "NUMERIC"
  assert_lookup_type :decimal, "number"
  assert_lookup_type :decimal, "number(2,8)"
  assert_lookup_type :decimal, "NUMBER"
end
test_decimal_without_scale() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 93
def test_decimal_without_scale
  if current_adapter?(:OracleAdapter)
    {
      decimal: %w{decimal(2) decimal(2,0) numeric(2) numeric(2,0)},
      integer: %w{number(2) number(2,0)}
    }
  else
    { decimal: %w{decimal(2) decimal(2,0) numeric(2) numeric(2,0) number(2) number(2,0)} }
  end.each do |expected_type, types|
    types.each do |type|
      cast_type = @connection.send(:type_map).lookup(type)

      assert_equal expected_type, cast_type.type
      assert_equal 2, cast_type.cast(2.1)
    end
  end
end
test_float_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 69
def test_float_types
  assert_lookup_type :float, "float"
  assert_lookup_type :float, "FLOAT"
  assert_lookup_type :float, "double"
  assert_lookup_type :float, "DOUBLE"
end
test_integer_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 76
def test_integer_types
  assert_lookup_type :integer, "integer"
  assert_lookup_type :integer, "INTEGER"
  assert_lookup_type :integer, "tinyint"
  assert_lookup_type :integer, "smallint"
  assert_lookup_type :integer, "bigint"
end
test_string_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 18
def test_string_types
  assert_lookup_type :string, "char"
  assert_lookup_type :string, "varchar"
  assert_lookup_type :string, "VARCHAR"
  assert_lookup_type :string, "varchar(255)"
  assert_lookup_type :string, "character varying"
end
test_text_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 33
def test_text_types
  assert_lookup_type :text, "text"
  assert_lookup_type :text, "TEXT"
  assert_lookup_type :text, "clob"
  assert_lookup_type :text, "CLOB"
end
test_time_types() click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 45
def test_time_types
  assert_lookup_type :time, "time"
  assert_lookup_type :time, "TIME"
end

Private Instance Methods

assert_lookup_type(type, lookup) click to toggle source
# File activerecord/test/cases/connection_adapters/type_lookup_test.rb, line 113
def assert_lookup_type(type, lookup)
  cast_type = @connection.send(:type_map).lookup(lookup)
  assert_equal type, cast_type.type
end