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

Configure placholder identifying character #16

Open
capc0 opened this issue Jan 22, 2021 · 1 comment
Open

Configure placholder identifying character #16

capc0 opened this issue Jan 22, 2021 · 1 comment

Comments

@capc0
Copy link

capc0 commented Jan 22, 2021

It would be awesome if we could configure what character acts as the identifiying char for the named attribute.

So instead of using : allow the usage of e.g. @

SELECT * FROM something WHERE id = :id

SELECT * FROM something WHERE id = @id

I want to utilize prepared statements in https://github.com/sidorares/node-mysql2 via .execute in combination with named parameters. Currently all of our code bases uses @ parameters in combination with .query and a custom queryFormat function that replaces these with the actual values.

@s-devaney
Copy link

s-devaney commented Mar 30, 2024

In case anybody else was wondering this, you can override the default character (?) by passing a placeholder property e.g.:

var toUnnamed = require('named-placeholders')({placeholder: '@');

Also the library supports Postgres-style positional placeholders using the undocumented toNumbered function

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