Module: Sequel::Dataset::NoAutoLiteralStrings

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

Instance Method Summary collapse

Instance Method Details

#filter_expr(expr = nil) ⇒ Object

Raise an error if passing a plain string or an array whose first entry is a plain string.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sequel/extensions/no_auto_literal_strings.rb', line 53

def filter_expr(expr = nil)
  case expr
  when LiteralString
    super
  when String
    raise Error, "plain string passed to a dataset filtering method"
  when Array
    if expr.first.is_a?(String) && !expr.first.is_a?(LiteralString)
      raise Error, "plain string passed to a dataset filtering method"
    end
    super
  else
    super
  end
end

#update_sql(values = OPTS) ⇒ Object

Raise an error if passing a plain string.



70
71
72
73
74
75
76
77
78
79
# File 'lib/sequel/extensions/no_auto_literal_strings.rb', line 70

def update_sql(values=OPTS)
  case values
  when LiteralString
    super
  when String
    raise Error, "plain string passed to a dataset filtering method"
  else
    super
  end
end