add insert/select per type specs

add last_insert_id
add Driver.quote
This commit is contained in:
Brian J. Cardiff 2016-01-31 14:03:05 -03:00
parent add75d86bf
commit 2e6e6ed7e5
3 changed files with 67 additions and 9 deletions

View file

@ -13,6 +13,10 @@ class SQLite3::Connection < DB::Connection
LibSQLite3.close_v2(self)
end
def last_insert_id : Int64
LibSQLite3.last_insert_rowid(self)
end
def to_unsafe
@db
end

View file

@ -2,6 +2,12 @@ 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('\'', "''")
end
end
DB.register_driver "sqlite3", SQLite3::Driver