8000 fix(postgres): expand typed json and nullable casts on the client by colinhacks · Pull Request #80 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

fix(postgres): expand typed json and nullable casts on the client - #80

Merged
colinhacks merged 3 commits into
mainfrom
structured-present
Oct 23, 2026
Merged

colinhacks merged 3 commits into
mainfrom
structured-present

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

When the database server carries the same engine (the handshake in engine/postgres/src/extension.rs), a Postgres statement is analyzed by the server whole, and the client rebuilds the statement's text with the lexer alone. Only a statement with a structured parameter was kept on the client, since structured::present recognised ::rows(…) and ::row(…) and nothing else. A typed JSON parameter (:doc::jsonb('…')) and a cast to nullable(…) (#79) went to the server too, and came back with the cast still in the text: .run() would send $1::nullable(int) or $1::jsonb('{…}') to Postgres, which refuses both.

present now also recognises a typed JSON cast and a nullable(…) cast, so such a statement is expanded and analyzed on the client, with the server answering its needs, as a structured parameter already is. A plain cast, ::jsonb included, still goes to the server whole.

  • engine/core/src/structured.rs: present checks the three casts the pass rewrites.
  • engine/postgres/src/api.rs: a test that, with the same engine in the server, ::rows(…), ::jsonb('…') and ::nullable(…) (in any spacing and case) never ask for the server's analysis, and ::int and ::jsonb do.
  • The three engine artifacts, rebuilt.

Checked: cargo build --workspace --all-targets with no warning, the engine tests, the full oracle with --strict-coverage, nub run typecheck, nub run test (none skipped), and nub run build. A parity run between the client engine and a server carrying this engine showed the two analyses differing on a nullable(…) statement before this change.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 19:48
@vercel
vercel Bot commented Oct 23, 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 23, 2026 8:33pm UTC

Request Review

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 insufficient remaining quota.

@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 critical issues. One minor doc-accuracy suggestion inline.

Reviewed changes

I reviewed how structured::present changed and how it decides which path a Postgres statement takes when the server's pgreylo extension has the same engine.

  • present covers every Postgres rewrite: it now also matches ::json(…)/::jsonb(…) and ::nullable(…), using the same helpers as find. On Postgres, the casts it matches are now exactly the ones the pass rewrites.
  • Client-side analysis for rewritten statements: with Server::Same, such a statement is now expanded and analyzed on the client, and no longer goes to the server through ANALYZE_QUERY. So .run() no longer receives $1::nullable(int) or $1::jsonb('…') in the text.
  • Routing test: the test checks the need ids for ANALYZE_QUERY. Bundled needs go through ANSWER_QUERY, which has a different prefix, so the negative asserts actually test something. Plain ::int and ::jsonb still go to the server.
  • Artifacts: all three engine.wasm files are rebuilt, as a change under engine/core/ requires.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread engine/core/src/structured.rs Resolved
@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

This run covered the commits pushed since the last Pullfrog review (ac9fd4f), which apply the earlier doc-accuracy suggestion.

  • Made present match find on MySQL and SQLite: a plain ::type after a placeholder now counts as a rewrite on dialects that have no ::. This uses the same dialect != Dialect::Postgres && plain_cast_at(…) check as find's own plain-cast branch, so the doc now holds on all three dialects. Postgres routing is unchanged.
  • Added present_is_whether_the_pass_rewrites_the_statement: covers each cast the pass rewrites on all three dialects, and checks that a plain ::int counts on MySQL and SQLite but not on Postgres.
  • Rebuilt the three engine artifacts: required because the change is under engine/core/.

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

@colinhacks
colinhacks merged commit 66125cc into main Oct 23, 2026
6 checks passed
@colinhacks
colinhacks deleted the structured-present branch October 23, 2026 20:40
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

0