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).
Instance Method Summary collapse
-
#bind_arguments ⇒ Object
The bind arguments to use for running this prepared statement.
-
#call(bind_vars = OPTS, &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.
-
#prepared_statement_name ⇒ Object
The name of the prepared statement, if any.
Instance Method Details
#bind_arguments ⇒ Object
The bind arguments to use for running this prepared statement
50 51 52 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 50 def bind_arguments @opts[:bind_arguments] end |
#call(bind_vars = OPTS, &block) ⇒ Object
Set the bind arguments based on the hash and call super.
55 56 57 58 59 60 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 55 def call(bind_vars=OPTS, &block) sql = prepared_sql prepared_args.freeze ps = bind(bind_vars) ps.clone(:bind_arguments=>ps.map_to_prepared_args(ps.opts[:bind_vars]), :sql=>sql, :prepared_sql=>sql).run(&block) end |
#prepared_sql ⇒ Object
Override the given *_sql method based on the type, and cache the result of the sql.
64 65 66 67 68 69 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 64 def prepared_sql if sql = @opts[:prepared_sql] || cache_get(:_prepared_sql) return sql end cache_set(:_prepared_sql, super) end |
#prepared_statement_name ⇒ Object
The name of the prepared statement, if any.
45 46 47 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 45 def prepared_statement_name @opts[:prepared_statement_name] end |