-
Notifications
You must be signed in to change notification settings - Fork 978
Description
Some of insert queries contains all columns of table as input parameters.
In that case generated method may apply model struct instead of ...Params struct.
For example following method
https://github.com/kyleconroy/sqlc/blob/bda1a0089e042a33f64f9dd1b59a2c3631fb659e/examples/ondeck/postgresql/city.sql.go#L28
may easily become
func (q *Queries) CreateCity(ctx context.Context, arg City) (City, error) {Because table contains two columns
https://github.com/kyleconroy/sqlc/blob/bda1a0089e042a33f64f9dd1b59a2c3631fb659e/examples/ondeck/postgresql/schema/0001_city.sql#L1-L4
and the query uses all of them
https://github.com/kyleconroy/sqlc/blob/bda1a0089e042a33f64f9dd1b59a2c3631fb659e/examples/ondeck/postgresql/query/city.sql#L15-L21
Implementation
For output parameters there is struct "deduplication"
https://github.com/kyleconroy/sqlc/blob/bda1a0089e042a33f64f9dd1b59a2c3631fb659e/internal/codegen/golang/result.go#L183
I believe we need to introduce the same deduplication for input parameters
https://github.com/kyleconroy/sqlc/blob/bda1a0089e042a33f64f9dd1b59a2c3631fb659e/internal/codegen/golang/result.go#L166