Replies: 3 comments 3 replies
-
Hi. Has anything become of this idea? |
Beta Was this translation helpful? Give feedback.
3 replies
-
Seems like a flag in -- name: PersistNewCity :entity :one
INSERT INTO city ( * ) VALUES ( ** )
RETURNING *; results in func (q *Queries) PersistNewCity(ctx context.Context, arg City) (City, error) { where expands |
Beta Was this translation helpful? Give feedback.
0 replies
-
+1 How do maintainers feel about it? We can probably help open a PR |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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
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
Beta Was this translation helpful? Give feedback.
All reactions