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:
Brian J. Cardiff 2016-11-29 20:14:07 -03:00
parent 73108c169e
commit fe0ed55ef9
8 changed files with 118 additions and 39 deletions

View file

@ -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