Include parameter name in codegen proto’s Parameter message #2845
-
| 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 | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| You can get this information from the column that's passed as part of the parameter. The  -- name: GetAuthor :one
SELECT * FROM authors
WHERE id = sqlc.arg('foo') LIMIT 1;{
  "number": 1,
  "column": {
    "name": "foo",
    "is_named_param": true
  }
} | 
Beta Was this translation helpful? Give feedback.
You can get this information from the column that's passed as part of the parameter. The
is_named_paramfield will also be set totrue.{ "number": 1, "column": { "name": "foo", "is_named_param": true } }