Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Postgres guide walks a pg project through draft, migrate, generate and runtime use, verified end to end against the docker-compose Postgres in packages/pg/test. It lists the gaps found while verifying: the simplified schema reader in packages/pg/src/impl/schema.ts drops serial/identity, enums, domains, functions, triggers, matviews, extensions, non-public schemas and generated columns, and pg typegen differs from SQLite for limit 1, returning, and nullable params. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs called Postgres a runtime adapter with toolchain docs 'still in progress'. Postgres has a working dialect (draft, migrate, check, generate, format, UI), so: README documents the dialect config key and points limitations at the guide's known gaps; adapters, errors, formatter, lint plugin and schema-diff pages say what's true for pg today (including that pg errors are always kind 'unknown'); the intro blog post links the guide; @sqlfu/pg gets a README so its npm page isn't empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main added a celld guide alongside the Postgres guides here. Both sides appended to the Guides description in sync-docs.mjs; kept both and regenerated llms.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Task file for step three item two of tasks/pg.md: limit 1 / FROM-less / aggregate selects, DML RETURNING, update data split and where-param nullability should generate the same wrappers on pg as on SQLite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit: |
Generates one project with SQLite and with pgDialect and asserts the wrapper signatures and namespace types match. All six cases fail today: limit 1 / FROM-less / aggregate selects return arrays, RETURNING wrappers call client.run, update SET params aren't split into data, and where params are typed nullable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New packages/pg/src/impl/query-shape.ts reads the pgsql-ast-parser AST plus catalog facts (unique indexes, column nullability, aggregate and set-returning functions) and fills the descriptor fields the shared wrapper generator keys off: - multipleRowsResult: false for limit 1, FROM-less selects, aggregates without group by, and lookups covering a unique index. DML is always single-row, as in typesql. Set-returning functions stay multi-row. - params: not-null unless tested with is [not] null or inserted/set into a nullable column. - data: update SET params, when they come before every other param. returning is set for DML that has result columns, so RETURNING wrappers call client.all and return the row instead of client.run. Analyzer fixtures now record multipleRowsResult (plus returning/data when set); new result-shape.md covers the pg-only rules. The Postgres guide's Known gaps list the differences that remain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
🤖 Folded into the shared Postgres PR #159 (branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sqlfu generatenow emits the same wrappers for Postgres as for SQLite. Before, a project that switched topgDialectgot arrays forlimit 1queries,client.runforinsert ... returning, andstring | nullfor everywhereparam.Given this in
sql/queries.sql:The new spec,
packages/pg/test/generate-parity.test.ts, runsgenerateon one project with each dialect and asserts the wrapper signatures and namespace types are identical.packages/pg/src/impl/query-shape.tspgsql-ast-parserAST and a few catalog facts (unique indexes, column nullability, aggregate and set-returning functions frompg_proc). It decides one row vs many, which params are nullable, and which update params are SET values. The rules copy typesql's SQLite analyzer, so the shared wrapper generator gets the same descriptor fields from both dialects.packages/pg/src/impl/typegen.tsanalyzeQueries, then uses the query shape formultipleRowsResult, paramnotNullanddata. Setsreturning: truefor DML that has result columns, which is what turnsclient.runintoclient.all+ row. If the AST parse fails, keeps today's loose shape (array, nullable params).packages/pg/test/generate-parity.test.tslimit 1, nofrom, aggregate, insert/delete RETURNING, update RETURNING, where params). Each pins SQLite's output in an inline snapshot and requires pg to equal it.packages/pg/test/fixtures/typegen/result-shape.mdor, window functions, set-returning functions,is nullparams, nullable insert/on conflicttargets, thedatasplit, and the parse-failure fallback.packages/pg/test/typegen-fixture-runner.ts+ everyfixtures/typegen/*.mdmultipleRowsResult, plusreturning/datawhen set. Where-params flip tonotNull: true.packages/sqlfu/docs/guides/postgres.mdfindPostBySlug. The "Generated wrappers" known gaps now list what's still different (see below) instead of the four fixed items.tasks/pg.md,tasks/complete/2026-10-29-pg-typegen-parity.mdBefore/after: analyzer fixtures
limitations.md›update-without-returning(update test_table set n = $1 where id = $2):dml-returning.mdcases gainreturning: trueandmultipleRowsResult: false. Every other case gains amultipleRowsResultline, and its where-params go fromnotNull: falsetotrue.Decisions to check
insert ... select ... returning. That's what typesql does. Fixing it is a change for both dialects, not a pg-only one.where slug = :slugreturnsResult | nulleven when the table also has a primary key. typesql only notices this when a table has exactly one unique column. SQLite is the buggy side here.select generate_series(1, 3)) stay multi-row even with nofrom. SQLite doesn't have them.tasks/complete/2026-05-07-pg-package.md; the columns already worked. The real gap was the row count, which is fixed here.Still different (now in the guide's Known gaps)
int8(count(*)) is typedbigintandnumericis typednumber, butpgreturns both as strings by default.client.runone.cast(...)drops not-null in the vendored pgkit nullability pass.pgsql-ast-parsercan't parse (is not distinct from,similar to) fall back to arrays and nullable params.Claude Code session:
local_ca9de0dd-5a56-41ce-8314-da6da8e927c1("Match Postgres typegen output to SQLite")🤖 Generated with Claude Code