Module: Sequel::Dataset::ArgumentMapper

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 Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bind_argumentsObject

The bind arguments to use for running this prepared statement



46
47
48
# File 'lib/sequel/dataset/prepared_statements.rb', line 46

def bind_arguments
  @bind_arguments
end

#prepared_statement_nameObject

The name of the prepared statement, if any.



43
44
45
# File 'lib/sequel/dataset/prepared_statements.rb', line 43

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.



49
50
51
52
53
54
# File 'lib/sequel/dataset/prepared_statements.rb', line 49

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_sqlObject

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



58
59
60
61
62
63
64
# File 'lib/sequel/dataset/prepared_statements.rb', line 58

def prepared_sql
  return @prepared_sql if @prepared_sql
  @prepared_args ||= []
  @prepared_sql = super
  @opts[:sql] = @prepared_sql
  @prepared_sql
end