class MiniSql::Postgres::PreparedConnection
Attributes
unprepared[R]
Public Class Methods
new(unprepared_connection)
click to toggle source
# File lib/mini_sql/postgres/prepared_connection.rb, line 9 def initialize(unprepared_connection) @unprepared = unprepared_connection @raw_connection = unprepared_connection.raw_connection @type_map = unprepared_connection.type_map @param_encoder = unprepared_connection.param_encoder @prepared_cache = PreparedCache.new(@raw_connection) @param_binder = PreparedBinds.new end
Public Instance Methods
build(_)
click to toggle source
# File lib/mini_sql/postgres/prepared_connection.rb, line 19 def build(_) raise 'Builder can not be called on prepared connections, instead of `::MINI_SQL.prepared.build(sql).query` use `::MINI_SQL.build(sql).prepared.query`' end
deserializer_cache()
click to toggle source
# File lib/mini_sql/postgres/prepared_connection.rb, line 27 def deserializer_cache @unprepared.deserializer_cache end
prepared(condition = true)
click to toggle source
# File lib/mini_sql/postgres/prepared_connection.rb, line 23 def prepared(condition = true) condition ? self : @unprepared end
Private Instance Methods
run(sql, params)
click to toggle source
# File lib/mini_sql/postgres/prepared_connection.rb, line 31 def run(sql, params) prepared_sql, binds, _bind_names = @param_binder.bind(sql, *params) prepare_statement_key = @prepared_cache.prepare_statement(prepared_sql) raw_connection.exec_prepared(prepare_statement_key, binds) end