Module: Sequel::Dataset::ArgumentMapper
- Included in:
- UnnumberedArgumentMapper, Oracle::Dataset::ArgumentMapper, Postgres::Dataset::ArgumentMapper, SQLite::Dataset::ArgumentMapper, TinyTDS::Dataset::ArgumentMapper
- Defined in:
- lib/sequel/dataset/prepared_statements.rb
Overview
Default implementation of the argument mapper to allow native database support for bind variables and prepared statements (as opposed to the emulated ones used by default).
Constant Summary collapse
- SQL_QUERY_TYPE =
Hash.new{|h,k| h[k] = k}
Instance Attribute Summary collapse
-
#bind_arguments ⇒ Object
The bind arguments to use for running this prepared statement.
-
#prepared_statement_name ⇒ Object
The name of the prepared statement, if any.
Instance Method Summary collapse
-
#call(bind_vars = {}, &block) ⇒ Object
Set the bind arguments based on the hash and call super.
-
#prepared_sql ⇒ Object
Override the given *_sql method based on the type, and cache the result of the sql.
Instance Attribute Details
#bind_arguments ⇒ Object
The bind arguments to use for running this prepared statement
22 23 24 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 22 def bind_arguments @bind_arguments end |
#prepared_statement_name ⇒ Object
The name of the prepared statement, if any.
19 20 21 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 19 def prepared_statement_name @prepared_statement_name end |
Instance Method Details
#call(bind_vars = {}, &block) ⇒ Object
Set the bind arguments based on the hash and call super.
25 26 27 28 29 30 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 25 def call(bind_vars={}, &block) ds = bind(bind_vars) ds.prepared_sql ds.bind_arguments = ds.map_to_prepared_args(ds.opts[:bind_vars]) ds.run(&block) end |
#prepared_sql ⇒ Object
Override the given *_sql method based on the type, and cache the result of the sql.
34 35 36 37 38 39 40 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 34 def prepared_sql return @prepared_sql if @prepared_sql @prepared_args ||= [] @prepared_sql = super @opts[:sql] = @prepared_sql @prepared_sql end |