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
|
||||
false
|
||||
else
|
||||
raise Exception.new(@statement.connection)
|
||||
raise Exception.new(sqlite3_statement.sqlite3_connection)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ class SQLite3::ResultSet < DB::ResultSet
|
|||
when Type::NULL
|
||||
nil
|
||||
else
|
||||
raise Exception.new(@statement.connection)
|
||||
raise Exception.new(sqlite3_statement.sqlite3_connection)
|
||||
end
|
||||
@column_index += 1
|
||||
value
|
||||
|
@ -68,12 +68,16 @@ class SQLite3::ResultSet < DB::ResultSet
|
|||
end
|
||||
|
||||
def to_unsafe
|
||||
@statement.to_unsafe
|
||||
sqlite3_statement.to_unsafe
|
||||
end
|
||||
|
||||
# :nodoc:
|
||||
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
|
||||
|
||||
private def moving_column
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class SQLite3::Statement < DB::Statement
|
||||
def initialize(connection, sql)
|
||||
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
|
||||
|
||||
protected def perform_query(args : Enumerable) : DB::ResultSet
|
||||
|
@ -17,8 +17,8 @@ class SQLite3::Statement < DB::Statement
|
|||
rs.move_next
|
||||
rs.close
|
||||
|
||||
rows_affected = LibSQLite3.changes(connection).to_i64
|
||||
last_id = LibSQLite3.last_insert_rowid(connection)
|
||||
rows_affected = LibSQLite3.changes(sqlite3_connection).to_i64
|
||||
last_id = LibSQLite3.last_insert_rowid(sqlite3_connection)
|
||||
|
||||
DB::ExecResult.new rows_affected, last_id
|
||||
end
|
||||
|
@ -65,7 +65,11 @@ class SQLite3::Statement < DB::Statement
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def to_unsafe
|
||||
|
|
Loading…
Reference in a new issue