Last Update: 2017-02-10 16:17:29 -0800

The implicit_subquery extension changes most dataset methods that return modified datasets to implicitly call from_self if the database currently uses raw SQL. Sequel's by default does not do this:

DB["SELECT * FROM table"].select(:column).sql
# => "SELECT * FROM table"

With this extension, datasets that use raw SQL are implicitly wrapped in a subquery:

DB["SELECT * FROM table"].select(:column).sql
# => "SELECT column FROM (SELECT * FROM table) AS t1"

To add this extension to an existing dataset:

ds = ds.extension(:implicit_subquery)

To set this as the default behavior for all datasets on a single database:


Related module: Sequel::Dataset::ImplicitSubquery