Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Include parameter name in codegen proto’s Parameter message #2845

Answered by kyleconroy
ciarand asked this question in Q&A
Discussion options

What do you want to change?

It would be helpful for debugging and better query generation if the codegen/plugin proto’s parameter message included the optional name of the parameter as provided by the author.

I am personally interested in generating better query templates for queries containing both slice params and regular params, which are currently broken (#2452). I haven’t filed an issue for it yet, but reusing the same slice parameter multiple times in the same query also doesn’t work currently (because we use strings.Replace with an N of 1) and would require some annoying counting without using named parameters.

What database engines need to be changed?

SQLite

What programming language backends need to be changed?

No response

You must be logged in to vote

You can get this information from the column that's passed as part of the parameter. The is_named_param field will also be set to true.

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = sqlc.arg('foo') LIMIT 1;
{
 "number": 1,
 "column": {
 "name": "foo",
 "is_named_param": true
 }
}

Replies: 1 comment

Comment options

You can get this information from the column that's passed as part of the parameter. The is_named_param field will also be set to true.

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = sqlc.arg('foo') LIMIT 1;
{
 "number": 1,
 "column": {
 "name": "foo",
 "is_named_param": true
 }
}
You must be logged in to vote
0 replies
Answer selected by kyleconroy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request ⚙️ WASM WASM plugins
Converted from issue

This discussion was converted from issue #2713 on October 12, 2023 23:53.

AltStyle によって変換されたページ (->オリジナル) /