Skip to content

fix: preserve PostgreSQL :: casts in Named queries#987

Open
leno23 wants to merge 2 commits into
jmoiron:masterfrom
leno23:fix/named-postgres-cast-956
Open

fix: preserve PostgreSQL :: casts in Named queries#987
leno23 wants to merge 2 commits into
jmoiron:masterfrom
leno23:fix/named-postgres-cast-956

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Fixes #956

sqlx.Named was rewriting PostgreSQL type casts like t.path::text to t.path:text, breaking queries that use :: for casts.

  • Preserve :: when it follows an identifier character (e.g. path::text)
  • Preserve :: when it follows a bound named parameter (e.g. :boundary::jsonb)
  • Refactor bindvar emission via appendBindvar helper

Also adds regression tests for the #956 report and the :param::type pattern from #983.

Test plan

  • go test ./...
  • TestNamedPostgresCastInIdentifier
  • TestNamedPostgresCastAfterNamedParam
  • Updated TestCompileQuery expectations for string literals containing ::

Made with Cursor

leno23 added 2 commits May 17, 2026 23:52
Document issue/PR expectations and local test workflow for new
contributors.
Fixes jmoiron#956 by treating :: after identifiers and after named
parameters as PostgreSQL type casts instead of consuming a colon.
Also covers :param::type patterns (e.g. jmoiron#983).
@leno23 leno23 force-pushed the fix/named-postgres-cast-956 branch from 621087d to 9e3a5ed Compare May 17, 2026 15:52
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.

Bug in sqlx.Named where ::text is incorrectly processed, leading to syntax erro

1 participant