Repository navigation
Support for naming hints via sqlc.arg in BETWEEN expressions #2277
Description
Activity
- addedenhancementNew feature or requestNew feature or requesttriageNew issues that hasn't been reviewedNew issues that hasn't been reviewed
on May 12, 2023 - addedbugSomething isn't workingSomething isn't workingand removedtriageNew issues that hasn't been reviewedNew issues that hasn't been reviewed
on Jun 6, 2023 - added a commit that references this issue
on Jun 24, 2023 Kyle added this to the milestone, and I'd like to have the next release, so I wrote a PR :P
The change was small, but finding where to make it was harder :)
(https://snoozeth.is/E8ZK_PmKi-g) I will wait until #2366 is merged and then add a comment.
- added a commit that references this issue
on Jun 24, 2023 I just realized I misread your feature request. I thought you wanted to have better default names than Date and Date_2. However, I made a drive-by fix that fixed reusing the same parameter number for both left and right and that probably fixed your actual request.
I've added a test case for your request to my PR.
@Jille perfect, testing with sqlc from your branch and it is working well, thank you!
As you mention, actually the "better defaults" behaviour actually satisfies the original bug without even needing the sqlc.arg support, but thanks for enabling that too
type GetEventByDateParams struct { FromDate time.Time ToDate time.Time }
Reacted by Jille Timmermans and penmanglewood- added 2 commits that reference this issue
on Jun 27, 2023 Resolved.
- added a commit that references this issue
on Jun 28, 2023 - added a commit that references this issue
on Jun 28, 2023 - added 2 commits that reference this issue
on Oct 13, 2025
What do you want to change?
Currently if you use a
BETWEENexpression such asSELECT id, name, date FROM events WHERE date BETWEEN ? AND ?;then sqlc simply names the struct fields asDateandDate_2a'la:It would be great if naming hints could be passed to sqlc as-in
LIKEexpressions so you could putSELECT id, name, date FROM events WHERE date BETWEEN sqlc.arg(from_date) AND sqlc.arg(to_date);and that would result in the generated struct fields beingFromDateandToDate. At the moment if you attempt to do that it breaks the parser and the Params struct is omitted entirely (playground link)What database engines need to be changed?
PostgreSQL, MySQL
What programming language backends need to be changed?
Go