[codex] Add query diagnostics CLI#32
Conversation
8b45591 to
a3618ac
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3618aceba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import fs from 'fs-extra'; | ||
| import pg from 'pg'; | ||
| import { processSQLQueryIR, QueryParameters } from 'pgtyped-rescript-runtime'; | ||
| import { getTypeData, IParseError, startup } from 'pgtyped-rescript-query'; |
There was a problem hiding this comment.
Bump query dependency for getTypeData
This import depends on a new pgtyped-rescript-query export, but packages/cli/package.json still allows any ^3.0.1 install and the previous 3.0.1 entry point did not export getTypeData. In a consumer lockfile that upgrades only pgtyped-rescript while keeping pgtyped-rescript-query@3.0.1, Node will fail to load the CLI before any command runs. Please raise the dependency floor to the first query package version that includes this export.
Useful? React with 👍 / 👎.
| queryIR.params.length > 0 && | ||
| !params |
There was a problem hiding this comment.
Ignore unused params when requiring diagnostics input
This guard treats declared-but-unused @param entries as requiring --params, because queryIR.params includes parameters that the parser only warns about as unused, while processSQLQueryIR later filters by usedParamSet. For a query whose SQL has no placeholders after unused declarations are ignored, diagnose --mode explain is blocked unless the user supplies dummy JSON even though the generated SQL needs no bindings.
Useful? React with 👍 / 👎.
a3618ac to
df42388
Compare
|
Addressed the Codex review feedback:
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df42388a89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ('fields' in parseResult) { | ||
| const { fields: errorFields } = parseResult; | ||
| return { | ||
| errorCode: errorFields.R, |
There was a problem hiding this comment.
Use SQLSTATE for parse error codes
When describe hits a server parse error, this fills errorCode from ErrorResponse field R, but PostgreSQL uses R for the backend routine and C for the SQLSTATE code (the wire test fixture includes both, e.g. C: '3D000' and R: 'InitPostgres'). This makes diagnostic JSON/text report unstable routine names such as scanner_yyerror instead of actionable SQLSTATEs like 42601.
Useful? React with 👍 / 👎.
df42388 to
2951748
Compare
|
Addressed the latest Codex review feedback:
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2951748d0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import crypto from 'crypto'; | ||
| import fs from 'fs-extra'; | ||
| import pg from 'pg'; | ||
| import { processSQLQueryIR, QueryParameters } from 'pgtyped-rescript-runtime'; |
There was a problem hiding this comment.
Declare the runtime dependency before importing it
This new import makes the CLI package depend directly on pgtyped-rescript-runtime, but packages/cli/package.json only adds pg and still does not declare the runtime package. In package managers with strict or non-hoisted installs, such as pnpm/Yarn PnP or nested npm layouts, pgtyped-rescript/lib/index.js cannot resolve transitive dependencies of pgtyped-rescript-query, so the CLI can fail at startup before any command runs. Please add pgtyped-rescript-runtime as a direct dependency of the CLI package.
Useful? React with 👍 / 👎.
2951748 to
438845d
Compare
|
Addressed latest Codex review feedback:
@codex review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds a
pgtyped-rescript diagnoseCLI command for quickly inspecting pgtyped SQL queries, and makes normal typegen output much quieter.What changed
diagnose <sqlFile>with modes fordescribe,explain, andanalyze.--list,--sql,--params,--params-file,--format, and--timeout.describeoutput with parameter labels, PostgreSQL type names, OIDs, and source columns.@paramdeclarations, and SQLSTATE parse error mapping.--verboseto restore detailed processing output such as worker pool size, per-file processing, per-file skips, and full summary counts.Review follow-up
pgtyped-rescript-querypublic export dependency from the CLI by keeping the wire-level describe helper local to the CLI.@paramdeclarations do not require dummy JSON.C) rather than backend routine (R) for parse error diagnostic codes.Validation
git diff --checknpm run check --workspace packages/clinpm run build --workspace packages/clinpm test --workspace packages/cli -- --runInBandnpm run lint -- --project packages/cli/tsconfig.jsondescribe,explain, andanalyze --format json --timeout 5s.--verbosetypegen output.