Method: String#lit

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

#lit(*args) ⇒ Object

Converts a string into a Sequel::LiteralString, in order to override string literalization, e.g.:

DB[:items].where(abc: 'def')
# "SELECT * FROM items WHERE (abc = 'def')"

DB[:items].where(abc: 'def'.lit)
# "SELECT * FROM items WHERE (abc = def)"

You can also provide arguments, to create a Sequel::SQL::PlaceholderLiteralString:

DB[:items].select{|o| o.count('DISTINCT ?'.lit(:a))}
# "SELECT count(DISTINCT a) FROM items"


184
185
186
# File 'lib/sequel/extensions/core_extensions.rb', line 184

def lit(*args)
  args.empty? ? Sequel::LiteralString.new(self) : Sequel::SQL::PlaceholderLiteralString.new(self, args)
end