-
Notifications
You must be signed in to change notification settings - Fork 861
Support for naming hints via sqlc.arg in BETWEEN expressions #2277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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. |
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
} |
Resolved. |
What do you want to change?
Currently if you use a
BETWEEN
expression such asSELECT id, name, date FROM events WHERE date BETWEEN ? AND ?;
then sqlc simply names the struct fields asDate
andDate_2
a'la:It would be great if naming hints could be passed to sqlc as-in
LIKE
expressions 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 beingFromDate
andToDate
. 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
The text was updated successfully, but these errors were encountered: