Last Modified
2013-07-31 01:34:14 +0000
Requires

Description

The query_literals extension changes Sequel's default behavior of the select, order and group methods so that if the first argument is a regular string, it is treated as a literal string, with the rest of the arguments (if any) treated as placeholder values. This allows you to write code such as:

DB[:table].select('a, b, ?', 2).group('a, b').order('c')

The default Sequel behavior would literalize that as:

SELECT 'a, b, ?', 2 FROM table GROUP BY 'a, b' ORDER BY 'c'

Using this extension changes the literalization to:

SELECT a, b, 2, FROM table GROUP BY a, b ORDER BY c

This extension makes select, group, and order methods operate like filter methods, which support the same interface.

There are very few places where Sequel's default behavior is desirable in this area, but for backwards compatibility, the defaults won't be changed until the next major release.

You can load this extension into specific datasets:

ds = DB[:table]
ds.extension(:query_literals)

Or you can load it into all of a database's datasets, which is probably the desired behavior if you are using this extension:

DB.extension(:query_literals)