sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.51k stars 810 forks source link

Support different parameter tags #3685

Closed adamgen closed 2 weeks ago

adamgen commented 2 weeks ago

What do you want to change?

Currently the sql accepts arguments using native sql notation $1.

Additionally I'd like to have a different parameter notation, for example pyformat %(my_param)s

To be more explicit - currently that's the only way to pass an argument

select *
from users
where id = $1

This is how I'd like to pass an argument

select *
from users
where id = %(id)s

What database engines need to be changed?

No response

What programming language backends need to be changed?

No response

kyleconroy commented 2 weeks ago

We support the database's native parameter format, usually ? or $1. In addition we also support the sqlc.arg macro, which is documented here. Support that macro has proved difficult enough that I have no plans to add additional parameter tags right now.