fix(golang): respect the engine on global type overrides - #4625
Open
xue-ding-e wants to merge 1 commit into
Open
xue-ding-e wants to merge 1 commit into
xue-ding-e wants to merge 1 commit into
Conversation
Filter global overrides before parsing them for a generation request. Rules without an engine continue to apply to single-engine configs, and matching rules retain their existing order and precedence. Add v1 and v2 end-to-end cases with PostgreSQL, MySQL and SQLite sharing column names and database types. Check model fields, query parameters, imports and struct tags against committed generated output. Fixes sqlc-dev#4624. Developed and validated with AI assistance.
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.
Fixes #4624.
Global Go overrides currently apply without checking
engine. If PostgreSQL, MySQL and SQLite share a column name or database type, one engine's Go type and struct tags can leak into the other generated packages.Filter global overrides by the generation request's engine before parsing them. Overrides without an engine still apply, and the remaining rules keep their existing order and precedence. No new configuration is introduced.
The v1 and v2 end-to-end cases generate all three engines from the same SQL inputs. Their golden files check model fields, query parameters, imports and struct tags. Both new cases fail against the original code and pass with the fix.
Validated on Windows with Go 1.26.5:
TestReplay/basego test ./internal/codegen/... ./internal/configgo vet ./internal/codegen/... ./internal/configgo build ./...The live-database/examples suite was not run locally; these regressions exercise static SQL analysis and code generation.
AI assistance was used for implementation, reproduction, testing and this description.