column types

update to connection_string
remove Driver.quote
This commit is contained in:
Brian J. Cardiff 2016-01-31 17:31:35 -03:00
parent 2e6e6ed7e5
commit dd5c10ba6e
4 changed files with 33 additions and 20 deletions

View file

@ -1,8 +1,7 @@
class SQLite3::Connection < DB::Connection
def initialize(options)
def initialize(connection_string)
super
filename = options["database"]
check LibSQLite3.open_v2(filename, out @db, (LibSQLite3::Flag::READWRITE | LibSQLite3::Flag::CREATE), nil)
check LibSQLite3.open_v2(connection_string, out @db, (LibSQLite3::Flag::READWRITE | LibSQLite3::Flag::CREATE), nil)
end
def prepare(query)

View file

@ -1,12 +1,6 @@
class SQLite3::Driver < DB::Driver
def build_connection
SQLite3::Connection.new(options)
end
# Quotes the given string, making it safe to use in an SQL statement.
# It replaces all instances of the single-quote character with two single-quote characters.
def self.quote(string)
string.gsub('\'', "''")
SQLite3::Connection.new(connection_string)
end
end

View file

@ -66,7 +66,15 @@ class SQLite3::ResultSet2 < DB::ResultSet
end
def column_type(index : Int32)
raise "not implemented"
case LibSQLite3.column_type(self, index)
when Type::INTEGER; Int64
when Type::FLOAT ; Float64
when Type::BLOB ; Slice(UInt8)
when Type::TEXT ; String
when Type::NULL ; Nil
else
raise "not implemented"
end
end
def to_unsafe