Repository navigation
fix(postgres): type the two placeholders Postgres would mistype - #45
Merged
Merged
Conversation
Postgres types an untyped `$n` from its context, which went wrong twice:
- a `param.of(type)` selected on its own has no context, so it bound as
text: a boolean came back as 'false', an array as '{}', and decoding
failed. It is now `CAST($n AS <type>)` in the select list.
- a fractional value compared with an integer column was typed int8 and
failed with `invalid input syntax for type bigint`. It now binds as
`$n::numeric`.
Nothing else is cast, so whole numbers and params compared with columns
keep using indexes, `real` columns still match, and an insert of a fraction
into an integer column is still refused rather than rounded.
`param.of` kinds were keyed by codec alone, and types share codecs
(`PG.int8`/`PG.float8`), so a kind could carry another type's SQL; they are
keyed by codec and SQL type now.
Fuzz model: ClickHouse float `%` is not IEEE fmod, and the matcher for the
upstream ClickHouse and()-absorption bug covers nested ORs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Makisuo
added this pull request to stack #46
October 23, 2026 00:18
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 23, 2026
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.
Postgres types an untyped
$nfrom its context, which went wrong twice:param.of(type)in a select list bound as text: a boolean came back as'false', an array as'{}', and decoding failed. It now binds as$n::<type>($1::boolean,$2::text[]), exact for the column it belongs to."Amount" > $1with 9.75 failedinvalid input syntax for type bigint. Fractional bound values cast tonumeric; whole numbers stay uncast so integer comparisons keep their index.param.ofkinds were keyed by codec alone, and types share codecs (PG.int8/PG.float8,PG.text/CH.string), so a kind could carry another type's SQL; they are keyed by codec and SQL type. The dialect'splaceholderhook now receives the encoded value. One SQL snapshot changes:param.of(PG.text)→$1::text.Also in the fuzz model: ClickHouse float
%is not IEEE fmod; the upstream ClickHouseand()bug matcher covers nested ORs. That ClickHouse 25.8 bug (WHERE a AND ((b AND a) OR a)→TOO_FEW_ARGUMENTS_FOR_FUNCTION, avoided byoptimize_extract_common_expressions = 0) is upstream and stays inknown-issues.ts.Verification: PGlite tests in
bound-literals.test.ts; full suite with ClickHouse live; fuzz at 30× with only the upstream issue left in the backlog — 58/58 green.Stack (merge bottom-up):
🤖 Generated with Claude Code