gravity: Add UNION and lock mode support to the sqlite query builder.