Class | Sequel::Unbinder |
In: |
lib/sequel/ast_transformer.rb
|
Parent: | ASTTransformer |
Unbinder is used to take a dataset filter and return a modified version that unbinds already bound values and returns a dataset with bound value placeholders and a hash of bind values. You can then prepare the dataset and use the bound variables to execute it with the same values.
This class only does a limited form of unbinding where the variable names and values can be associated unambiguously. The only cases it handles are <tt>SQL::ComplexExpression<tt> with an operator in UNBIND_OPS, a first argument that‘s an instance of a member of UNBIND_KEY_CLASSES, and a second argument that‘s an instance of a member of UNBIND_VALUE_CLASSES.
So it can handle cases like:
DB.filter(:a=>1).exclude(:b=>2).where{c > 3}
But it cannot handle cases like:
DB.filter(:a + 1 < 0)
UNBIND_OPS | = | [:'=', :'!=', :<, :>, :<=, :>=] | The <tt>SQL::ComplexExpression<tt> operates that will be considered for transformation. | |
UNBIND_KEY_CLASSES | = | [Symbol, SQL::Identifier, SQL::QualifiedIdentifier] | The key classes (first argument of the ComplexExpression) that will considered for transformation. | |
UNBIND_VALUE_CLASSES | = | [Numeric, String, Date, Time] | The value classes (second argument of the ComplexExpression) that will be considered for transformation. |
binds | [R] | The hash of bind variables that were extracted from the dataset filter. |