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].filter(:abc => 'def').sql #=>
"SELECT * FROM items WHERE (abc = 'def')"
DB[:items].filter(:abc => 'def'.lit).sql #=>
"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))}.sql #=>
"SELECT count(DISTINCT a) FROM items"
187 188 189 |
# File 'lib/sequel/extensions/core_extensions.rb', line 187 def lit(*args) args.empty? ? Sequel::LiteralString.new(self) : Sequel::SQL::PlaceholderLiteralString.new(self, args) end |