mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
introduce unprepared statements
* rename QueryMethods#prepare to QueryMethods#build * rename Connection#build_statement to Connection#build_prepared_statement * add Connection#build_unprepared_statement * add Connection #prepared and #unprepared dsl methods
This commit is contained in:
parent
73108c169e
commit
fe0ed55ef9
8 changed files with 118 additions and 39 deletions
|
@ -22,8 +22,12 @@ class DummyDriver < DB::Driver
|
|||
@@connections.try &.clear
|
||||
end
|
||||
|
||||
def build_statement(query)
|
||||
DummyStatement.new(self, query)
|
||||
def build_prepared_statement(query)
|
||||
DummyStatement.new(self, query, true)
|
||||
end
|
||||
|
||||
def build_unprepared_statement(query)
|
||||
DummyStatement.new(self, query, false)
|
||||
end
|
||||
|
||||
def last_insert_id : Int64
|
||||
|
@ -46,7 +50,7 @@ class DummyDriver < DB::Driver
|
|||
class DummyStatement < DB::Statement
|
||||
property params
|
||||
|
||||
def initialize(connection, @query : String)
|
||||
def initialize(connection, @query : String, @prepared : Bool)
|
||||
@params = Hash(Int32 | String, DB::Any).new
|
||||
super(connection)
|
||||
end
|
||||
|
@ -79,6 +83,10 @@ class DummyDriver < DB::Driver
|
|||
raise "not implemented for #{value.class}"
|
||||
end
|
||||
|
||||
def prepared?
|
||||
@prepared
|
||||
end
|
||||
|
||||
protected def do_close
|
||||
super
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue