Skip to content

Support for naming hints via sqlc.arg in BETWEEN expressions #2277

Closed
@dnwe

Description

@dnwe

What do you want to change?

Currently if you use a BETWEEN expression such as SELECT id, name, date FROM events WHERE date BETWEEN ? AND ?; then sqlc simply names the struct fields as Date and Date_2 a'la:

type GetEventByDateParams struct {
	Date   sql.NullTime
	Date_2 sql.NullTime
}

It would be great if naming hints could be passed to sqlc as-in LIKE expressions so you could put SELECT 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 being FromDate and ToDate. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions