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

PostgreSQL specific argument mapper used for mapping the named argument hash to a array with numbered arguments. Only used with the pg driver.

Methods

Included Modules

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

Constants

SQL_QUERY_TYPE = Hash.new{|h,k| h[k] = k}

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 25
25:       def call(bind_vars={}, &block)
26:         ds = bind(bind_vars)
27:         ds.prepared_sql
28:         ds.bind_arguments = ds.map_to_prepared_args(ds.opts[:bind_vars])
29:         ds.run(&block)
30:       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 34
34:       def prepared_sql
35:         return @prepared_sql if @prepared_sql
36:         @prepared_args ||= []
37:         @prepared_sql = super
38:         meta_def("#{sql_query_type}_sql"){|*args| prepared_sql}
39:         @prepared_sql
40:       end

Protected Instance methods

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 218
218:         def map_to_prepared_args(hash)
219:           args = {}
220:           hash.each{|k,v| args[k.to_s.gsub('.', '__')] = v}
221:           args
222:         end

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

[Source]

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

[Validate]