Skip to content

Easier inserts with many columns #587

Answered by kyleconroy
alecbz asked this question in General
Discussion options

You must be logged in to vote

and I imagine sqlc wants to stay out of the business of guessing which columns are and aren't necessary in an insert statement.

You are correct that I'd like sqlc to avoid guessing which columns should be included and which ones shouldn't.

When adding SQL enhancements, I like to add them as functions in the sqlc namespace. So maybe it should look like this?

-- name: InsertThing :one
INSERT INTO members (a, lot, of, fields, that, this, type, of, data, has)
VALUES (sqlc.args())
RETURNING *;

or

-- name: InsertThing :one
INSERT INTO members (a, lot, of, fields, that, this, type, of, data, has)
VALUES sqlc.values()
RETURNING *;

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kyleconroy
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #587 on August 23, 2020 19:57.