Module: Sequel::Plugins::PreparedStatementsWithPk

Defined in:
lib/sequel/plugins/prepared_statements_with_pk.rb

Overview

The prepared_statements_with_pk plugin allows Dataset#with_pk for model datasets to use prepared statements by extract the values of previously bound variables using Dataset#unbind, and attempting to use a prepared statement if the variables can be unbound correctly. See Unbinder for details about what types of dataset filters can be unbound correctly.

This plugin depends on the prepared_statements plugin and should be considered unsafe. Unbinding dataset values cannot be done correctly in all cases, and use of this plugin in cases where not there are variables that are not unbound can lead to an denial of service attack by allocating an arbitrary number of prepared statements. You have been warned.

Usage:

# Make all model subclasses use prepared statements for Dataset#with_pk (called before loading subclasses)
Sequel::Model.plugin :prepared_statements_with_pk

# Make the Album class use prepared statements for Dataset#with_pk
Album.plugin :prepared_statements_with_pk

Defined Under Namespace

Modules: ClassMethods, DatasetMethods

Class Method Summary collapse

Class Method Details

.apply(model) ⇒ Object

Depend on the prepared_statements plugin



24
25
26
# File 'lib/sequel/plugins/prepared_statements_with_pk.rb', line 24

def self.apply(model)
  model.plugin(:prepared_statements)
end