Skip to content

Support unbounded parameter limit #2349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ The `gen` mapping supports the following keys:
- `output_files_suffix`:
- If specified the suffix will be added to the name of the generated files.
- `query_parameter_limit`:
- Positional arguments that will be generated in Go functions (>= `1` or `-1`). To always emit a parameter struct, you would need to set it to `-1`. `0` is invalid. Defaults to `1`.
`rename`:
- Positional arguments that will be generated in Go functions (>= `1` or `-1`). To always emit a parameter struct, you would need to set it to `1`. While `-1` is used to always generate all positional arguments. `0` is invalid. Defaults to `1`.
- `rename`:
- Customize the name of generated struct fields. Explained in detail on the `Renaming fields` section.
- `overrides`:
- It is a collection of definitions that dictates which types are used to map a database types. Explained in detail on the `Type overriding` section.
Expand Down
2 changes: 1 addition & 1 deletion internal/codegen/golang/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func buildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error)
EmitPointer: req.Settings.Go.EmitParamsStructPointers,
}

if len(query.Params) <= qpl {
if len(query.Params) <= qpl || qpl == -1 {
gq.Arg.Emit = false
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/config/v_two.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ func v2ParseConfig(rd io.Reader) (Config, error) {
conf.SQL[j].Gen.Go.Package = filepath.Base(conf.SQL[j].Gen.Go.Out)
}

if conf.SQL[j].Gen.Go.QueryParameterLimit != nil && (*conf.SQL[j].Gen.Go.QueryParameterLimit < 0) {
if conf.SQL[j].Gen.Go.QueryParameterLimit != nil && (*conf.SQL[j].Gen.Go.QueryParameterLimit == 0 ||
*conf.SQL[j].Gen.Go.QueryParameterLimit < -1) {
return conf, ErrInvalidQueryParameterLimit
}

Expand Down