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

Named bindings feature request #174

Open
elmeister opened this issue Feb 1, 2023 · 1 comment
Open

Named bindings feature request #174

elmeister opened this issue Feb 1, 2023 · 1 comment

Comments

@elmeister
Copy link

Hello
Thanks for the awesome library

Knex has a nice named bindings option, which allows to use :parametersWithColon (see docs), which in turn are supported in RDBMS editors, so we don't have to replace all ${id} with :id manually each time we're testing raw SQL
The check that named parameters are present looks pretty straightforward
How about adding something similar to sql-template-strings, so we would be able to build queries like this i.e.

sql`
SELECT * FROM books 
  WHERE id = :bookId
`.bind({ bookId })
@tracker1
Copy link

Really, if you want to use that kind of syntax, you're better off using the underlying database adapter directly, most of which already support that syntax. JS telmplate strings only naturally support the ordinal position, and your suggestion really wouldn't add much in terms of support. Also, not all the database backends currently in place support named parameters vs ordinal position.

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

2 participants