Class: Sequel::SQL::PlaceholderLiteralString
- Inherits:
-
GenericExpression
- Object
- Expression
- GenericExpression
- Sequel::SQL::PlaceholderLiteralString
- Defined in:
- lib/sequel/sql.rb
Overview
Represents a literal string with placeholders and arguments. This is necessary to ensure delayed literalization of the arguments required for the prepared statement support and for database-specific literalization.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
The arguments that will be subsituted into the placeholders.
-
#parens ⇒ Object
readonly
Whether to surround the expression with parantheses.
-
#str ⇒ Object
readonly
The literal string containing placeholders.
Instance Method Summary collapse
-
#initialize(str, args, parens = false) ⇒ PlaceholderLiteralString
constructor
Create an object with the given string, placeholder arguments, and parens flag.
Methods included from SubscriptMethods
Methods included from StringMethods
Methods included from OrderMethods
Methods included from NumericMethods
Methods included from ComplexExpressionMethods
#extract, #sql_boolean, #sql_number, #sql_string
Methods included from CastMethods
#cast, #cast_numeric, #cast_string
Methods included from BooleanMethods
Methods included from AliasMethods
Methods inherited from Expression
#==, attr_reader, comparison_attrs, #eql?, #hash, #inspect, #lit, #sql_literal
Constructor Details
#initialize(str, args, parens = false) ⇒ PlaceholderLiteralString
Create an object with the given string, placeholder arguments, and parens flag.
866 867 868 869 870 |
# File 'lib/sequel/sql.rb', line 866 def initialize(str, args, parens=false) @str = str @args = args.is_a?(Array) && args.length == 1 && (v = args.at(0)).is_a?(Hash) ? v : args @parens = parens end |
Instance Attribute Details
#args ⇒ Object (readonly)
The arguments that will be subsituted into the placeholders. Either an array of unnamed placeholders (which will be substituted in order for ? characters), or a hash of named placeholders (which will be substituted for :key phrases).
857 858 859 |
# File 'lib/sequel/sql.rb', line 857 def args @args end |
#parens ⇒ Object (readonly)
Whether to surround the expression with parantheses
863 864 865 |
# File 'lib/sequel/sql.rb', line 863 def parens @parens end |
#str ⇒ Object (readonly)
The literal string containing placeholders
860 861 862 |
# File 'lib/sequel/sql.rb', line 860 def str @str end |