Method: Sequel::Plugins::Finder::ClassMethods#prepared_finder
- Defined in:
- lib/sequel/plugins/finder.rb
#prepared_finder(meth = OPTS, opts = OPTS, &block) ⇒ Object
Similar to finder, but uses a prepared statement instead of a placeholder literalizer. This makes the SQL used static (cannot vary per call), but allows binding argument values instead of literalizing them into the SQL query string.
If a block is used with this method, it is instance_execed by the model, and should accept the desired number of placeholder arguments.
The options are the same as the options for finder, with the following exception:
- :type
-
Specifies the type of prepared statement to create
185 186 187 188 189 190 191 192 193 |
# File 'lib/sequel/plugins/finder.rb', line 185 def prepared_finder(meth=OPTS, opts=OPTS, &block) if block raise Error, "cannot pass both a method name argument and a block of Model.finder" unless meth.is_a?(Hash) meth = meth.merge(:prepare=>true) else opts = opts.merge(:prepare=>true) end finder(meth, opts, &block) end |