Module: Sequel::Dataset::AutoLiteralStrings

Defined in:
lib/sequel/extensions/auto_literal_strings.rb

Instance Method Summary collapse

Instance Method Details

#filter_expr(expr = nil) ⇒ Object

Treat plain strings as literal strings, and arrays where the first element is a string as a literal string with placeholders.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/sequel/extensions/auto_literal_strings.rb', line 41

def filter_expr(expr = nil)
  case expr
  when LiteralString
    super
  when String
    super(LiteralString.new(expr))
  when Array
    if (sexpr = expr.first).is_a?(String)
      super(SQL::PlaceholderLiteralString.new(sexpr, expr[1..-1], true))
    else
      super
    end
  else
    super
  end
end

#update_sql(values = OPTS) ⇒ Object

Treat plain strings as literal strings.



59
60
61
62
63
64
65
66
67
68
# File 'lib/sequel/extensions/auto_literal_strings.rb', line 59

def update_sql(values=OPTS)
  case values
  when LiteralString
    super
  when String
    super(LiteralString.new(values))
  else
    super
  end
end