Class: Sequel::SQL::PlaceholderLiteralString

Inherits:
SpecificExpression show all
Defined in:
lib/sequel_core/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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#lit

Constructor Details

#initialize(str, args, parens = false) ⇒ PlaceholderLiteralString

Create an object with the given conditions and default value.



673
674
675
676
677
# File 'lib/sequel_core/sql.rb', line 673

def initialize(str, args, parens=false)
  @str = str
  @args = args
  @parens = parens
end

Instance Attribute Details

#argsObject (readonly)

The arguments that will be subsituted into the placeholders.



663
664
665
# File 'lib/sequel_core/sql.rb', line 663

def args
  @args
end

#parensObject (readonly)

Whether to surround the expression with parantheses



669
670
671
# File 'lib/sequel_core/sql.rb', line 669

def parens
  @parens
end

#strObject (readonly)

The literal string containing placeholders



666
667
668
# File 'lib/sequel_core/sql.rb', line 666

def str
  @str
end

Instance Method Details

#to_s(ds) ⇒ Object

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.



681
682
683
# File 'lib/sequel_core/sql.rb', line 681

def to_s(ds)
  ds.placeholder_literal_string_sql(self)
end