Methods
I
Q
S
T
Instance Public methods
id()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 93
def id
  10
end
quoted_id()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 89
def quoted_id
  "'zomg'"
end
setup()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 10
def setup
  @conn = Base.sqlite3_connection :database => ':memory:',
    :adapter => 'sqlite3',
    :timeout => 100
end
test_quoting_binary_strings()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 107
def test_quoting_binary_strings
  value = "hello".encode('ascii-8bit')
  column = Column.new(nil, 1, Type::String.new)

  assert_equal "'hello'", @conn.quote(value, column)
end
test_type_cast_bigdecimal()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 77
def test_type_cast_bigdecimal
  bd = BigDecimal.new '10.0'
  assert_equal bd.to_f, @conn.type_cast(bd, nil)
end
test_type_cast_binary_encoding_without_logger()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 16
def test_type_cast_binary_encoding_without_logger
  @conn.extend(Module.new { def logger; end })
  column = Column.new(nil, nil, Type::String.new)
  binary = SecureRandom.hex
  expected = binary.dup.encode!(Encoding::UTF_8)
  assert_equal expected, @conn.type_cast(binary, column)
end
test_type_cast_date()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 28
def test_type_cast_date
  date = Date.today
  expected = @conn.quoted_date(date)
  assert_equal expected, @conn.type_cast(date, nil)
end
test_type_cast_false()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 55
def test_type_cast_false
  c = Column.new(nil, 1, Type::Integer.new)
  assert_equal 'f', @conn.type_cast(false, nil)
  assert_equal 0, @conn.type_cast(false, c)
end
test_type_cast_nil()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 45
def test_type_cast_nil
  assert_equal nil, @conn.type_cast(nil, nil)
end
test_type_cast_numeric()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 40
def test_type_cast_numeric
  assert_equal 10, @conn.type_cast(10, nil)
  assert_equal 2.2, @conn.type_cast(2.2, nil)
end
test_type_cast_object_which_responds_to_quoted_id()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 87
def test_type_cast_object_which_responds_to_quoted_id
  quoted_id_obj = Class.new {
    def quoted_id
      "'zomg'"
    end

    def id
      10
    end
  }.new
  assert_equal 10, @conn.type_cast(quoted_id_obj, nil)

  quoted_id_obj = Class.new {
    def quoted_id
      "'zomg'"
    end
  }.new
  assert_raise(TypeError) { @conn.type_cast(quoted_id_obj, nil) }
end
test_type_cast_string()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 61
def test_type_cast_string
  assert_equal '10', @conn.type_cast('10', nil)

  c = Column.new(nil, 1, Type::Integer.new)
  assert_equal 10, @conn.type_cast('10', c)

  c = Column.new(nil, 1, Type::Float.new)
  assert_equal 10.1, @conn.type_cast('10.1', c)

  c = Column.new(nil, 1, Type::Binary.new)
  assert_equal '10.1', @conn.type_cast('10.1', c)

  c = Column.new(nil, 1, Type::Date.new)
  assert_equal '2016-05-11', @conn.type_cast('2016-05-11 19:00:00', c)
end
test_type_cast_symbol()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 24
def test_type_cast_symbol
  assert_equal 'foo', @conn.type_cast(:foo, nil)
end
test_type_cast_time()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 34
def test_type_cast_time
  time = Time.now
  expected = @conn.quoted_date(time)
  assert_equal expected, @conn.type_cast(time, nil)
end
test_type_cast_true()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 49
def test_type_cast_true
  c = Column.new(nil, 1, Type::Integer.new)
  assert_equal 't', @conn.type_cast(true, nil)
  assert_equal 1, @conn.type_cast(true, c)
end
test_type_cast_unknown_should_raise_error()
# File activerecord/test/cases/adapters/sqlite3/quoting_test.rb, line 82
def test_type_cast_unknown_should_raise_error
  obj = Class.new.new
  assert_raise(TypeError) { @conn.type_cast(obj, nil) }
end