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.
Direct Known Subclasses
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.
-
#with_parens ⇒ Object
Return a copy of the that will be surrounded by parantheses.
Methods included from IsDistinctFrom::Methods
Methods included from Sequel::SQLite::JSONOpMethods
#sqlite_json_op, #sqlite_jsonb_op
Methods included from Postgres::HStoreOpMethods
Methods included from Postgres::RangeOpMethods
Methods included from Postgres::ArrayOpMethods
Methods included from Postgres::JSONOpMethods
Methods included from Postgres::InetOpMethods
Methods included from Postgres::PGRowOp::ExpressionMethods
Methods included from SubscriptMethods
Methods included from StringMethods
#escaped_ilike, #escaped_like, #ilike, #like
Methods included from PatternMatchMethods
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, #clone, #eql?, #hash, inherited, #inspect
Constructor Details
#initialize(str, args, parens = false) ⇒ PlaceholderLiteralString
Create an object with the given string, placeholder arguments, and parens flag.
1626 1627 1628 1629 1630 1631 |
# File 'lib/sequel/sql.rb', line 1626 def initialize(str, args, parens=false) @str = str @args = args.is_a?(Array) && args.length == 1 && (v = args[0]).is_a?(Hash) ? v : args @parens = parens freeze 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).
1620 1621 1622 |
# File 'lib/sequel/sql.rb', line 1620 def args @args end |
#parens ⇒ Object (readonly)
Whether to surround the expression with parantheses
1623 1624 1625 |
# File 'lib/sequel/sql.rb', line 1623 def parens @parens end |
#str ⇒ Object (readonly)
The literal string containing placeholders. This can also be an array of strings, where each arg in args goes between the string elements.
1614 1615 1616 |
# File 'lib/sequel/sql.rb', line 1614 def str @str end |
Instance Method Details
#with_parens ⇒ Object
Return a copy of the that will be surrounded by parantheses.
1634 1635 1636 |
# File 'lib/sequel/sql.rb', line 1634 def with_parens @parens ? self : self.class.new(@str, @args, true) end |