Title: Fix parameter handling in CAST expressions for duplicate params by kyleconroy · Pull Request #4384 · sqlc-dev/sqlc · GitHub
Open Graph Title: Fix parameter handling in CAST expressions for duplicate params by kyleconroy · Pull Request #4384 · sqlc-dev/sqlc
X Title: Fix parameter handling in CAST expressions for duplicate params by kyleconroy · Pull Request #4384 · sqlc-dev/sqlc
Description: Summary This PR fixes parameter handling in SQL queries that use CAST expressions with duplicate parameters. Previously, parameters used multiple times within CAST functions were not properly tracked as named parameters, causing incorrect code generation. Fixes #4376 Key Changes Schema Update: Added age column to the test users table to support the new test case Model Update: Added Age field to the User struct to reflect the schema change Query Addition: Added SelectUserByAgeCast test query that uses the same parameter twice within CAST expressions Compiler Fix: Modified resolveCatalogRefs in internal/compiler/resolve.go to properly track whether a parameter is named when resolving CAST type references Now captures the isNamed return value from params.FetchMerge() Sets col.IsNamedParam = isNamed to correctly mark parameters used in CAST expressions Implementation Details The fix ensures that when a parameter appears multiple times in a query (particularly within CAST expressions), the compiler correctly identifies it as a named parameter and generates the appropriate Go code. This prevents duplicate parameter passing and ensures proper parameter binding in the generated SQL execution code. https://claude.ai/code/session_011tJhgjfWrTPw9yY4EpeJXG
Open Graph Description: Summary This PR fixes parameter handling in SQL queries that use CAST expressions with duplicate parameters. Previously, parameters used multiple times within CAST functions were not properly track...
X Description: Summary This PR fixes parameter handling in SQL queries that use CAST expressions with duplicate parameters. Previously, parameters used multiple times within CAST functions were not properly track...
Opengraph URL: https://github.com/sqlc-dev/sqlc/pull/4384
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:03eeb2ca-6b93-3cd3-7c45-ea2fb0acede7 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8DAA:111468:36D21:491BD:6A510EC3 |
| html-safe-nonce | 505861b4075ebba4204aa989d84567dcba2a468cc7c50be4dba5340e523e44fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REFBOjExMTQ2ODozNkQyMTo0OTFCRDo2QTUxMEVDMyIsInZpc2l0b3JfaWQiOiI5MTUxMTY2OTQ2ODMzNjY1NzMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2a902f0984f25dd29e9386290aac68192217c73f99e0afb1664bddfadde2bb30 |
| hovercard-subject-tag | pull_request:3545522588 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/sqlc-dev/sqlc/pull/4384/files |
| twitter:image | https://avatars.githubusercontent.com/u/34893?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/34893?s=400&v=4 |
| og:image:alt | Summary This PR fixes parameter handling in SQL queries that use CAST expressions with duplicate parameters. Previously, parameters used multiple times within CAST functions were not properly track... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b076e100febaa00374cd89239f915d00dd3187f7c68b12bc2b7688181305344d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/sqlc-dev/sqlc git https://github.com/sqlc-dev/sqlc.git |
| octolytics-dimension-user_id | 136738596 |
| octolytics-dimension-user_login | sqlc-dev |
| octolytics-dimension-repository_id | 193160679 |
| octolytics-dimension-repository_nwo | sqlc-dev/sqlc |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193160679 |
| octolytics-dimension-repository_network_root_nwo | sqlc-dev/sqlc |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f9137f6d981cbbfd780af369f80ce890b2d0d2d4 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width