Skip to content

fix(golang): respect the engine on global type overrides - #4625

Open
xue-ding-e wants to merge 1 commit into
sqlc-dev:mainfrom
xue-ding-e:fix/go-global-overrides-engine
Open

xue-ding-e wants to merge 1 commit into
sqlc-dev:mainfrom
xue-ding-e:fix/go-global-overrides-engine

Conversation

@xue-ding-e

Copy link
Copy Markdown

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:

  • 34 existing and new overrides cases in TestReplay/base
  • go test ./internal/codegen/... ./internal/config
  • go vet ./internal/codegen/... ./internal/config
  • go build ./...
  • Compilation of all six generated fixture packages

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.

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.
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.

Global Go type overrides ignore the engine selector

1 participant