Skip to content

Restructure queries config into include/exclude lists#51

Merged
iamralch merged 1 commit into
mainfrom
feat/queries-include-exclude
Jun 8, 2026
Merged

Restructure queries config into include/exclude lists#51
iamralch merged 1 commit into
mainfrom
feat/queries-include-exclude

Conversation

@iamralch

@iamralch iamralch commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

⚠️ Breaking change. Restructures options.queries from a flat list of opt-in query names into an object with include/exclude lists, mirroring the options.tables shape from #49.

# before
options:
  queries:
    - "CopyUsers"

# after
options:
  queries:
    include:
      - "CopyUsers"   # add an opt-in query on top of the defaults
    exclude:
      - "DeleteUser"  # drop a default you don't want

Semantics (additive)

Generated set = (defaults ∪ include) − exclude.

include exclude Result
empty empty the default query set (unchanged behavior)
set empty defaults plus the included opt-in queries
empty set defaults minus the excluded queries
set set (defaults + include) − exclude; exclude wins

include adds opt-in queries on top of the default set (it does not replace it), so adding one query never drops the defaults. exclude removes queries — including defaults like DeleteUser — and always takes precedence.

New capability

queries.exclude lets you drop an unwanted default query for the first time (e.g. DeleteUser).

Implementation notes

  • CodegenOptions.Queries is now QueryOptions{Include, Exclude}; GetQueriesSetGetQueryIncludeSet / GetQueryExcludeSet.
  • The template's previously unconditional Insert/ExecInsert/BatchInsert/BatchExecInsert and base List are now gated as defaults, so they honor exclude too. All gating funnels through one predicate: should_generate $ $query_name $isDefault = (isDefault || included) && !excluded.
  • The legacy flat-list form no longer parses (clean break).

Migration

Move existing queries: [...] entries under queries.include.

Validation

  • go build ./..., go test ./..., nix build .#default
  • Manually generated against the test catalog: default mode emits all 15 defaults; include: [CopyUsers] + exclude: [DeleteUser] adds CopyUsers and drops only DeleteUser while keeping every other default.

@iamralch iamralch changed the title Restructure queries config into include/exclude allow-list Restructure queries config into include/exclude lists Jun 8, 2026
@iamralch iamralch force-pushed the feat/queries-include-exclude branch from 85440c8 to 744483a Compare June 8, 2026 05:05
options.queries changes from a flat list of opt-in query
names to an object with include/exclude lists, mirroring options.tables.

Generated set is (defaults ∪ include) − exclude:
- include adds opt-in queries on top of the default set (it does not replace
  it), so adding one query never drops the defaults.
- exclude removes queries from what would otherwise be generated, including
  defaults (e.g. DeleteUser), and always takes precedence over include.
- an empty include + empty exclude yields the default query set (unchanged).

The template now gates the previously-unconditional Insert family and base
List query through a unified should_generate predicate so they honor exclude
too. The legacy flat list form (queries: [..]) no longer parses; move those
entries under queries.include.
@iamralch iamralch force-pushed the feat/queries-include-exclude branch from 744483a to f8de261 Compare June 8, 2026 05:13
@iamralch iamralch merged commit 697f49e into main Jun 8, 2026
2 checks passed
@iamralch iamralch deleted the feat/queries-include-exclude branch June 8, 2026 05:13
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Code Metrics Report

Coverage Test Execution Time
84.5% 46s

Code coverage of files in pull request scope (81.9%)

Files Coverage
internal/sqlc/config.go 95.5%
internal/sqlc/generator.go 74.0%

Reported by octocov

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.

1 participant