2016-12-03 18:56:03 +00:00
|
|
|
module DB
|
|
|
|
# Represents a statement to be executed in any of the connections
|
|
|
|
# of the pool. The statement is not be executed in a non prepared fashion.
|
|
|
|
# The execution of the statement is retried according to the pool configuration.
|
|
|
|
#
|
|
|
|
# See `PoolStatement`
|
2023-12-08 22:06:41 +00:00
|
|
|
struct PoolUnpreparedStatement < PoolStatement
|
2016-12-03 19:03:50 +00:00
|
|
|
def initialize(db : Database, query : String)
|
|
|
|
super
|
2016-12-03 18:56:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# builds a statement over a real connection
|
2019-08-02 14:54:52 +00:00
|
|
|
private def build_statement : Statement
|
2017-09-07 22:21:36 +00:00
|
|
|
conn = @db.pool.checkout
|
|
|
|
begin
|
|
|
|
conn.unprepared.build(@query)
|
|
|
|
rescue ex
|
|
|
|
conn.release
|
|
|
|
raise ex
|
|
|
|
end
|
2016-12-03 18:56:03 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|