Skip to content

fix(engine): cast the value in the repeated-parameter error's example - #14

Merged
colinhacks merged 1 commit into
mainfrom
fix-repeated-param-cast
Oct 22, 2026
Merged

colinhacks merged 1 commit into
mainfrom
fix-repeated-param-cast

Conversation

@colinhacks

Copy link
Copy Markdown
Owner

A parameter used twice is an error whose message suggests reading it once through a with:

The parameter :id appears more than once; use each parameter once, and select it in a with to read it twice, as in: with input as (select :id as id) select … from input

Followed as written, that rewrite fails on every dialect, because nothing types a bare parameter in a select list:

  • Postgres reads it as text: with input as (select :id as id) select c.* from book_comments c, input where c.id = input.id or c.user_id = input.id is "operator does not exist: integer = text (42883)".
  • SQLite leaves it untyped, which is the "Nothing in the statement gives the parameter :min a type" error under strict_params.
  • MySQL types it as a string.

With a cast (select :id::int as id), each dialect types it. The message now says so:

… select it in a with to read it twice, cast to its type, as in: with input as (select :id::<type> as id) select … from input
  • engine/core/src/lex.rs: the message and its unit test.
  • tests/analyze.test.ts and the oracle cases that record the message (params_once, sqlite_params_once, sqlite_inserts, mysql_types).
  • The three engine.wasm artifacts, rebuilt for core's new fingerprint.

Checked locally: the Rust build and engine tests, the oracle on Postgres 18, SQLite and MySQL 8.4, the wasm fingerprints, the typecheck, and the loader tests (192 passing, none skipped).

Copilot AI balanced review requested due to automatic review settings October 22, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reylo Ready Ready Preview Oct 22, 2026 5:24pm UTC

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the change to the reylo3 repeated-parameter diagnostic's example, which now casts the value in the suggested with.

  • Diagnostic text — repeated() in engine/core/src/lex.rs now suggests with input as (select :x::<type> as x) select … from input, with a comment on why a bare parameter in a select list is untyped on each dialect.
  • The ::<type> form works on every dialect — engine/core/src/structured.rs rewrites a ::type after a parameter into MySQL's and SQLite's own CAST, so following the suggestion works on all three dialects, not just Postgres.
  • Fixtures — the lex unit tests, tests/analyze.test.ts, and the params_once, sqlite_params_once, sqlite_inserts and mysql_types oracle outputs all match the new text. No other copy of the message (README or docs) needed updating.
  • Artifacts — the three engine.wasm builds were regenerated for core's new fingerprint.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

The error suggested `with input as (select :id as id)`, which no
dialect types: Postgres reads a bare parameter in a select list as
text, MySQL as a string, and SQLite leaves it untyped. The example now
casts it, `select 🆔:<type> as id`.
@colinhacks
colinhacks force-pushed the fix-repeated-param-cast branch from 452c4e9 to cb9c1d0 Compare October 22, 2026 17:24
@colinhacks
colinhacks merged commit 0e8d9ea into main Oct 22, 2026
4 checks passed
@colinhacks
colinhacks deleted the fix-repeated-param-cast branch October 22, 2026 17:28
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.

2 participants