Skip to content

fix(postgres): type names from the database analyzer, enums, escaped … - #75

Open
timohuovinen wants to merge 1 commit into
sqlc-dev:mainfrom
Wind-Growth:wind-growth/postgres-fixes
Open

timohuovinen wants to merge 1 commit into
sqlc-dev:mainfrom
Wind-Growth:wind-growth/postgres-fixes

Conversation

@timohuovinen

Copy link
Copy Markdown

…query text

sqlc's database analyzer names types the way format_type prints them (integer, boolean, timestamp(3) with time zone, numeric(12,2)); the type tables only knew the pg_type names, so those parameters and computed columns fell back to string, and postgres.js sends a string given for a boolean parameter as false. Both spellings now map to the same type in the postgres and pg drivers, modifiers dropped.

  • Enum types become string literal unions, from the catalog.
  • postgres driver: date and timestamp parameters take Date | string.
  • The query is emitted as a template literal with backslash, backtick and ${ escaped, so '\%' reaches the database as written.
  • Each query file is emitted once instead of once per query.
  • Code generation moves to src/codegen.ts so tests run it under Node: npm test (no database) and npm run test:postgres (analyzer-generated code run with postgres.js); CI runs both against PostgreSQL 17.
  • A vX.Y.Z tag publishes the WASM as a release asset with its sha256.

…query text

sqlc's database analyzer names types the way format_type prints them
(integer, boolean, timestamp(3) with time zone, numeric(12,2)); the type
tables only knew the pg_type names, so those parameters and computed columns
fell back to string, and postgres.js sends a string given for a boolean
parameter as false. Both spellings now map to the same type in the postgres
and pg drivers, modifiers dropped.

- Enum types become string literal unions, from the catalog.
- postgres driver: date and timestamp parameters take Date | string.
- The query is emitted as a template literal with backslash, backtick and
  ${ escaped, so `'\%'` reaches the database as written.
- Each query file is emitted once instead of once per query.
- Code generation moves to src/codegen.ts so tests run it under Node:
  npm test (no database) and npm run test:postgres (analyzer-generated code
  run with postgres.js); CI runs both against PostgreSQL 17.
- A vX.Y.Z tag publishes the WASM as a release asset with its sha256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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