diff --git a/docs/reference/config.md b/docs/reference/config.md index a3c430744f..07c2dacadb 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -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. diff --git a/internal/codegen/golang/result.go b/internal/codegen/golang/result.go index f5ecd124a1..86b749aed8 100644 --- a/internal/codegen/golang/result.go +++ b/internal/codegen/golang/result.go @@ -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 } } diff --git a/internal/config/v_two.go b/internal/config/v_two.go index e2c97a2749..d0c835265f 100644 --- a/internal/config/v_two.go +++ b/internal/config/v_two.go @@ -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 }