Skip to content

Include comments inside the generated SQL statement #2207

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

Open
fr3fou opened this issue Apr 14, 2023 · 2 comments
Open

Include comments inside the generated SQL statement #2207

fr3fou opened this issue Apr 14, 2023 · 2 comments

Comments

@fr3fou
Copy link

fr3fou commented Apr 14, 2023

What do you want to change?

Hi!

I'd like to use sqlmw interceptors with sqlcache.
sqlcache relies on query "annotations", like so:

-- name: GetUsers :many
-- @cache-ttl 30
-- @cache-max-rows 10
SELECT * FROM users;

However, upon generating the code, those comments get stripped out and instead got shoved on top of the generated Go method. Is there a way to prevent this from happening?

// @cache-ttl 30
// @cache-max-rows 10
func (q *Queries) GetUsers(ctx context.Context) ([]User, error) {

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

@fr3fou fr3fou added enhancement New feature or request triage New issues that hasn't been reviewed labels Apr 14, 2023
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang and removed triage New issues that hasn't been reviewed labels Jun 7, 2023
@kyleconroy
Copy link
Collaborator

Currently there isn't a way to change this behavior, but your use case makes sense.

@kyleconroy kyleconroy changed the title Is there a way to include comments inside the generated SQL statement? Include comments inside the generated SQL statement Jun 7, 2023
@jskelcy
Copy link
Contributor

jskelcy commented Oct 28, 2024

Ill one up this for pgpool users, where you can add a comment to override routing decisions made by pgpool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants