Method: Sequel::Dataset#call
- Defined in:
- lib/sequel/dataset/prepared_statements.rb
#call(type, bind_variables = OPTS, *values, &block) ⇒ Object
For the given type, run the sql with the bind variables specified in the hash. values is a hash passed to insert or update (if one of those types is used), which may contain placeholders.
The following types are supported:
-
:select, :all, :each, :first, :single_value, :insert, :insert_select, :insert_pk, :update, :delete
-
Array where first element is :map, :as_hash, :to_hash, :to_hash_groups (remaining elements are passed to the related method)
DB.where(id: :$id).call(:first, id: 1) # SELECT * FROM table WHERE id = ? LIMIT 1 – (1) # => :id=>1
DB.where(id: :$id).call(:update, 1, id: 2, col: :$c) # UPDATE table WHERE id = ? SET col = ? – (2, 1) # => 1
377 378 379 |
# File 'lib/sequel/dataset/prepared_statements.rb', line 377 def call(type, bind_variables=OPTS, *values, &block) to_prepared_statement(type, values, :extend=>bound_variable_modules).call(bind_variables, &block) end |