Gravity: Add grouping support to database DML query builders.

This starts off with support for grouping conditional statements
(on, where, having), but can be extended in the future to also support
for example unions.