mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
Added some casts to make it work when other drivers are loaded
This commit is contained in:
parent
84e1eed991
commit
c3fce779fe
2 changed files with 16 additions and 8 deletions
|
@ -18,7 +18,7 @@ class SQLite3::ResultSet < DB::ResultSet
|
||||||
when LibSQLite3::Code::DONE
|
when LibSQLite3::Code::DONE
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
raise Exception.new(@statement.connection)
|
raise Exception.new(sqlite3_statement.sqlite3_connection)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class SQLite3::ResultSet < DB::ResultSet
|
||||||
when Type::NULL
|
when Type::NULL
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
raise Exception.new(@statement.connection)
|
raise Exception.new(sqlite3_statement.sqlite3_connection)
|
||||||
end
|
end
|
||||||
@column_index += 1
|
@column_index += 1
|
||||||
value
|
value
|
||||||
|
@ -68,12 +68,16 @@ class SQLite3::ResultSet < DB::ResultSet
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_unsafe
|
def to_unsafe
|
||||||
@statement.to_unsafe
|
sqlite3_statement.to_unsafe
|
||||||
end
|
end
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
private def step
|
private def step
|
||||||
LibSQLite3::Code.new LibSQLite3.step(@statement)
|
LibSQLite3::Code.new LibSQLite3.step(sqlite3_statement)
|
||||||
|
end
|
||||||
|
|
||||||
|
protected def sqlite3_statement
|
||||||
|
@statement.as(Statement)
|
||||||
end
|
end
|
||||||
|
|
||||||
private def moving_column
|
private def moving_column
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class SQLite3::Statement < DB::Statement
|
class SQLite3::Statement < DB::Statement
|
||||||
def initialize(connection, sql)
|
def initialize(connection, sql)
|
||||||
super(connection)
|
super(connection)
|
||||||
check LibSQLite3.prepare_v2(@connection, sql, sql.bytesize + 1, out @stmt, nil)
|
check LibSQLite3.prepare_v2(sqlite3_connection, sql, sql.bytesize + 1, out @stmt, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected def perform_query(args : Enumerable) : DB::ResultSet
|
protected def perform_query(args : Enumerable) : DB::ResultSet
|
||||||
|
@ -17,8 +17,8 @@ class SQLite3::Statement < DB::Statement
|
||||||
rs.move_next
|
rs.move_next
|
||||||
rs.close
|
rs.close
|
||||||
|
|
||||||
rows_affected = LibSQLite3.changes(connection).to_i64
|
rows_affected = LibSQLite3.changes(sqlite3_connection).to_i64
|
||||||
last_id = LibSQLite3.last_insert_rowid(connection)
|
last_id = LibSQLite3.last_insert_rowid(sqlite3_connection)
|
||||||
|
|
||||||
DB::ExecResult.new rows_affected, last_id
|
DB::ExecResult.new rows_affected, last_id
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,11 @@ class SQLite3::Statement < DB::Statement
|
||||||
end
|
end
|
||||||
|
|
||||||
private def check(code)
|
private def check(code)
|
||||||
raise Exception.new(@connection) unless code == 0
|
raise Exception.new(sqlite3_connection) unless code == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
protected def sqlite3_connection
|
||||||
|
@connection.as(Connection)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_unsafe
|
def to_unsafe
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue