Skip to content

test(compiler): run reference service subqueries, CTEs, and bulk writes - #83

Merged
omer-cengel merged 1 commit into
masterfrom
chore/reference-service-nested-queries-and-multi-row-writes
Oct 14, 2026
Merged

omer-cengel merged 1 commit into
masterfrom
chore/reference-service-nested-queries-and-multi-row-writes

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

The reference service now exercises the nested-query and multi-row write shapes sqlcj analyzes: its membership checks compile without subquery casts, and new queries covering subqueries, CTEs, multi-row and SELECT-sourced inserts, and joined writes run against PostgreSQL 16 through the generated repository. This proves those shapes on a realistic migration history rather than only in focused tests.

Changes

  • Remove the ::bigint casts from the EXISTS and IN (SELECT ...) membership checks; their placeholders are now typed from columns, and the existing assertions pass unchanged.
  • Add reference queries for a NOT EXISTS check, a CTE report joined to projects, an aliased subquery source with a LIMIT placeholder, a two-row VALUES insert sharing one placeholder, an INSERT ... SELECT ... unnest(:userIds::bigint[]) ON CONFLICT DO NOTHING, an INSERT ... SELECT from tasks, an UPDATE ... FROM projects ... RETURNING t.*, and a DELETE ... USING tasks.
  • Add an integration test that runs each new query against PostgreSQL 16 in its own organization, asserting row counts, the correlated NOT EXISTS filter, the CTE counts at two priority bounds, the subquery LIMIT, and that the joined update returns the shared task row record.
  • Add a recursive CTE and a data-modifying CTE to the unsupported query catalogue, each rejected with its whole located diagnostic and no generated output.
  • Update the query documentation's verified-by lines for the reference service.

Scope and non-goals

  • No production code, migrations, or schema snapshot change; the migration history, hand-written snapshot, and pg_dump snapshot still generate one byte-identical tree with the same file set.
  • The cast in the projection scalar subquery of ListTasksWithRecentComments stays, since projection subqueries are still typed only by casts.
  • Recursive and data-modifying CTEs, set operations, LATERAL, views as sources, JDBC batch execution, COPY, and aggregate typing remain unsupported.

Drop the subquery casts the membership checks no longer need, and add a
NOT EXISTS check, a CTE report, a subquery source, a multi-row insert, an
unnest bulk insert, an INSERT ... SELECT, an UPDATE ... FROM, and a
DELETE ... USING to the reference service, each executed against
PostgreSQL 16 through the generated repository. The unsupported
catalogue gains a recursive and a data-modifying CTE.
@omer-cengel
omer-cengel merged commit 60e2327 into master Oct 14, 2026
7 checks passed
@omer-cengel
omer-cengel deleted the chore/reference-service-nested-queries-and-multi-row-writes branch October 14, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant