title: SQL support and limitations description: What the current compiler supports, where it is deliberately constrained, and what remains planned. #
StitchQL validates a defined SQL subset. The current implementation targets PostgreSQL 18 and uses an embedded PostgreSQL 17.7 parser grammar. PostgreSQL 18 syntax outside that grammar or the compiler's supported shapes can still be rejected. The default Go build needs no C toolchain.
These boundaries describe the current implementation, not a promise that every PostgreSQL statement can be translated unchanged.
Query features #
| Area | Supported |
|---|---|
| Sources | Ordinary tables, views, materialized views, derived SELECTs, and LATERAL sources |
| Joins | INNER, LEFT, RIGHT, FULL with ON/USING; CROSS JOIN |
| Results | Explicit columns, expressions with aliases, functions, CASE, COALESCE, casts, and columns fragments |
| Filtering | Supported scalar/boolean expressions, NULL and distinctness tests, predicates, EXISTS, and scalar/IN subqueries |
| Composition | Read/write CTEs, supported recursive CTEs, and UNION/INTERSECT/EXCEPT with ALL variants |
| Aggregation | GROUP BY, HAVING, supported built-in aggregates, FILTER, and supported aggregate ordering/distinctness |
| Windows | Ordinary window functions and supported aggregates with OVER, named windows, and frames |
| Pagination | ORDER BY supported expressions, aliases or ordinals; LIMIT and OFFSET |
| Collections | ARRAY subqueries and supported scalar arrays |
| Inserts | Explicit VALUES rows, DEFAULT VALUES, INSERT SELECT, and ON CONFLICT |
| Updates | Explicit SET assignments, scalar expressions, optional patch fields, and supported FROM sources |
| Deletes | One target table with a required WHERE clause |
| Returned mutations | INSERT, UPDATE, and DELETE with RETURNING |
Restrictions vary by SQL position. Result expressions support more forms than WHERE. For example, ordinary function calls and casts in WHERE remain restricted even though they are supported in result expressions. PostgreSQL still validates types, operators, grouping rules, and execution-time constraints.
Unsupported query forms #
The following forms are not currently supported in StitchQL query declarations. The examples show the SQL or clause that triggers the limitation:
| Feature | Unsupported example |
|---|---|
| Row locking | SELECT b.id FROM books AS b FOR UPDATE; also FOR SHARE and FOR KEY SHARE |
| Pattern matching in query conditions | WHERE b.title LIKE 'Kind%' or WHERE b.title ILIKE 'kind%' |
| Selecting all columns in the outer query | SELECT * FROM books or SELECT b.* FROM books AS b |
| Removing duplicate result rows with DISTINCT | SELECT DISTINCT b.title FROM books AS b |
| Joins based on automatically matched column names | FROM books NATURAL JOIN authors |
| Comparing a value with ANY/ALL subquery results | WHERE b.id > ALL (SELECT a.id FROM archived_books AS a); likewise = ANY (SELECT ...) |
| Including tied rows at a page boundary | ORDER BY b.title FETCH FIRST 10 ROWS WITH TIES |
| Sorting with an explicit operator | ORDER BY b.title USING < |
| Deleting through joined sources | DELETE FROM books AS b USING authors AS a WHERE b.author_id = a.id |
| Deleting the row at a cursor's current position | DELETE FROM books WHERE CURRENT OF book_cursor |
| Overriding identity-column behavior on insert | INSERT INTO books (id, title) OVERRIDING SYSTEM VALUE VALUES (1, 'Kindred') |
| COPY statements | COPY books (title) FROM STDIN |
Some similar forms are supported: count(*) and count(DISTINCT b.title)
work in supported aggregate positions, and LIKE can appear in schema CHECK
constraints. Cursor-based deletion means PostgreSQL's WHERE CURRENT OF; it
does not mean filtering by an ID, such as DELETE FROM books WHERE id < {before}.
Other limitations concern the source or Go input rather than a SQL clause:
- Inheritance and partitioning: a query such as
SELECT b.id FROM books AS bis rejected ifbooksis an inheritance parent or a partitioned table. - Optional INSERT fields:
stitchql.Optional[T]patch fields work in UPDATE declarations, but cannot make INSERT columns or values conditional. - Bulk-copy generation: StitchQL does not generate a bulk-insert API using PostgreSQL COPY.
- Source parameters require named relations:
[b books]binds tobooks. A predicate usingb.idcannot automatically accept any table with anidcolumn; structural source interfaces are not implemented.
Use handwritten SQL for operations that need unsupported forms, preserving their locking and filtering behavior.
Schema features #
Schema blocks support CREATE SCHEMA, ordinary CREATE TABLE, CREATE TYPE AS ENUM, indexes, views, and materialized views. Reusable fields and dependency ordering work across a package. Schema annotations do not change SQL type names or labels.
Arbitrary migration statements do not belong in schema blocks. Refreshing a materialized view, transforming existing data, or applying schema SQL is an explicit application or migration step. Schema index fragments, parameterized fields, and cross-package fields composition remain future work.
Migration generation also depends on pg-schema-diff coverage. The current
dependency cannot validate rebuilding an indexed materialized view; that failure
is reported without writing a migration.
Application boundaries #
StitchQL does not generate application authorization, transactions, retry loops, resource-name parsing, or transport models. API filter parsing, protobuf bridges, and field-mask translation are planned, not available APIs.
Runtime predicate composition works today through authored predicates and
stitchql.And, Or, and Not. A generated field/operator predicate-construction
API is a separate, unimplemented design.
The repository's SPEC.md describes the detailed language contract. PLAN.md
tracks pending work, and HISTORY.md records earlier increments whose old
restrictions may have been superseded.