Module Sequel::Dataset::ArgumentMapper
In: lib/sequel/adapters/postgres.rb
lib/sequel/adapters/sqlite.rb
lib/sequel/dataset/prepared_statements.rb

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).

Methods

Included Modules

Sequel::Dataset::ArgumentMapper Sequel::Dataset::ArgumentMapper

Attributes

bind_arguments  [RW]  The bind arguments to use for running this prepared statement
prepared_statement_name  [RW]  The name of the prepared statement, if any.

Public Instance methods

Set the bind arguments based on the hash and call super.

[Source]

    # File lib/sequel/dataset/prepared_statements.rb, line 22
22:       def call(bind_vars={}, &block)
23:         ds = bind(bind_vars)
24:         ds.prepared_sql
25:         ds.bind_arguments = ds.map_to_prepared_args(ds.opts[:bind_vars])
26:         ds.run(&block)
27:       end

Override the given *_sql method based on the type, and cache the result of the sql.

[Source]

    # File lib/sequel/dataset/prepared_statements.rb, line 31
31:       def prepared_sql
32:         return @prepared_sql if @prepared_sql
33:         @prepared_args ||= []
34:         @prepared_sql = super
35:         @opts[:sql] = @prepared_sql
36:         @prepared_sql
37:       end

Protected Instance methods

An array of bound variable values for this query, in the correct order.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 503
503:           def map_to_prepared_args(hash)
504:             prepared_args.map{|k| hash[k.to_sym]}
505:           end

Return a hash with the same values as the given hash, but with the keys converted to strings.

[Source]

     # File lib/sequel/adapters/sqlite.rb, line 221
221:         def map_to_prepared_args(hash)
222:           args = {}
223:           hash.each{|k,v| args[k.to_s.gsub('.', '__')] = v}
224:           args
225:         end

[Validate]