Skip to content
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

Ability to use ":" instead of "@" in named args #2177

Open
KoNekoD opened this issue Nov 22, 2024 · 8 comments
Open

Ability to use ":" instead of "@" in named args #2177

KoNekoD opened this issue Nov 22, 2024 · 8 comments

Comments

@KoNekoD
Copy link

KoNekoD commented Nov 22, 2024

Add ability to use ":" instead of "@" in named args

Sql linter in golang like this

@KoNekoD
Copy link
Author

KoNekoD commented Nov 22, 2024

@KoNekoD
Copy link
Author

KoNekoD commented Nov 22, 2024

PR #2178

Before(bad)

image

image

After (good)

image

@jackc
Copy link
Owner

jackc commented Nov 29, 2024

: is tricky because it is also used for type conversion, e.g. select somecol::text. As far as I can tell, #2178 would fail when :: is encountered.

But even if the parser was fixed I'd rather there only be way to denote a named argument.

However, pgx.[Strict]NamedArgs does not require any internal pgx functionality. It simply implements the pgx.QueryRewriter interface. If you really need to use :, you can copy NamedArgs into your project and change it there.

@KoNekoD
Copy link
Author

KoNekoD commented Dec 1, 2024

@jackc I see your point, I'll make the edits according to your concerns.

@KoNekoD
Copy link
Author

KoNekoD commented Dec 1, 2024

@jackc Done; Commit 2aa476d

This implementation turns out to be independent and takes into account cases of type casts

@jackc
Copy link
Owner

jackc commented Dec 5, 2024

The code looks more solid now.

But as I said above, I want to keep the simplicity of only having a single delimiter for named arguments.

I think this support for : should be pulled out into your own library or application.

@KoNekoD
Copy link
Author

KoNekoD commented Dec 7, 2024

@jackc Are you sure that library users will be comfortable being forced to adjust to your understanding of good? There seem to be some people who don't like it when their IDE frowns on '@' substitutions. Maybe we should pay attention to the convenience for the end user of the library?

@Nerobrain
Copy link

@KoNekoD Are you sure that library users will be comfortable being forced to adjust to your understanding of good? There seem to be some people who know difference between errors and linter faults. Maybe we should pay attention to the workload for the autor of the library?

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

No branches or pull requests

3 participants