mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Add type argument to QueryMethods module (#108)
This commit is contained in:
parent
0100b47754
commit
adc755e5e4
10 changed files with 30 additions and 30 deletions
|
@ -3,7 +3,7 @@ require "./spec_helper"
|
|||
module GenericResultSet
|
||||
@index = 0
|
||||
|
||||
def move_next
|
||||
def move_next : Bool
|
||||
@index = 0
|
||||
true
|
||||
end
|
||||
|
@ -48,11 +48,11 @@ class FooDriver < DB::Driver
|
|||
end
|
||||
|
||||
class FooConnection < DB::Connection
|
||||
def build_prepared_statement(query)
|
||||
def build_prepared_statement(query) : DB::Statement
|
||||
FooStatement.new(self)
|
||||
end
|
||||
|
||||
def build_unprepared_statement(query)
|
||||
def build_unprepared_statement(query) : DB::Statement
|
||||
raise "not implemented"
|
||||
end
|
||||
end
|
||||
|
@ -111,11 +111,11 @@ class BarDriver < DB::Driver
|
|||
end
|
||||
|
||||
class BarConnection < DB::Connection
|
||||
def build_prepared_statement(query)
|
||||
def build_prepared_statement(query) : DB::Statement
|
||||
BarStatement.new(self)
|
||||
end
|
||||
|
||||
def build_unprepared_statement(query)
|
||||
def build_unprepared_statement(query) : DB::Statement
|
||||
raise "not implemented"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,11 +22,11 @@ class DummyDriver < DB::Driver
|
|||
@@connections.try &.clear
|
||||
end
|
||||
|
||||
def build_prepared_statement(query)
|
||||
def build_prepared_statement(query) : DB::Statement
|
||||
DummyStatement.new(self, query, true)
|
||||
end
|
||||
|
||||
def build_unprepared_statement(query)
|
||||
def build_unprepared_statement(query) : DB::Statement
|
||||
DummyStatement.new(self, query, false)
|
||||
end
|
||||
|
||||
|
@ -102,13 +102,13 @@ class DummyDriver < DB::Driver
|
|||
raise DB::Error.new(query) if query == "syntax error"
|
||||
end
|
||||
|
||||
protected def perform_query(args : Enumerable)
|
||||
protected def perform_query(args : Enumerable) : DB::ResultSet
|
||||
@connection.as(DummyConnection).check
|
||||
set_params args
|
||||
DummyResultSet.new self, @query
|
||||
end
|
||||
|
||||
protected def perform_exec(args : Enumerable)
|
||||
protected def perform_exec(args : Enumerable) : DB::ExecResult
|
||||
@connection.as(DummyConnection).check
|
||||
set_params args
|
||||
raise DB::Error.new("forced exception due to query") if @query == "raise"
|
||||
|
@ -161,16 +161,16 @@ class DummyDriver < DB::Driver
|
|||
@@last_result_set.not_nil!
|
||||
end
|
||||
|
||||
def move_next
|
||||
def move_next : Bool
|
||||
@values = @top_values.shift?
|
||||
!!@values
|
||||
end
|
||||
|
||||
def column_count
|
||||
def column_count : Int32
|
||||
@column_count
|
||||
end
|
||||
|
||||
def column_name(index)
|
||||
def column_name(index) : String
|
||||
"c#{index}"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue