jschaf / pggen

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.
MIT License
281 stars 26 forks source link

Generated code for insert func, individual parameters vs single struct #69

Closed jaohurtas closed 2 years ago

jaohurtas commented 2 years ago

Not an issue just a question. I see the example here of the generated code for authors uses go types and individual parameters e.g. based on that I would expect something like this func InsertSomething (ctx context.Context, name string, address string,...)

Instead for my query it generates something like this: func InsertSomething (ctx context.Context, params InsertSomethingParams).

Can this behavior be controlled?

jschaf commented 2 years ago

Current behavior: if there's 0, 1, or 2 parameters, the parameters are inlined. If there's 3 or more parameters, pggen generates a struct.

The behavior is not configurable. I'm conservative with adding toggles since each one increases the testing surface.

jaohurtas commented 2 years ago

Thanks