moskytw/mosql — pull request #12 by uranusjr (2013-10-05 06:15:56+00:00)
Title: Support subqueries

Based on the discussion in #9.

I added an extra layer `_query` between `str` and `raw` to use internally. `Statement`-based callables and `identifier` now both return a `_query` object instead of `str`. This difference is used in `identifier` to avoid applying unintended processing to `_query` objects that represent subqueries.

Now you can do this:

subquery = select('person', select=('last_name',))
print select('person', where={'first_name': paren(subquery)})

And get:

SELECT * FROM "person" WHERE "first_name" = (SELECT "last_name" FROM "person")

The above test has been added to `build.select`.