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

Parameter binding does not work as portrayed on readme #951

Open
pedrolcn opened this issue Jan 1, 2021 · 2 comments
Open

Parameter binding does not work as portrayed on readme #951

pedrolcn opened this issue Jan 1, 2021 · 2 comments

Comments

@pedrolcn
Copy link

pedrolcn commented Jan 1, 2021

In the readme there doesn't seem to be a consensus as to what character should the parameter placeholder on prepared queries be. Some examples use ? while some examples use $1, $2, $3, .... Let`s enumerate them by section:

Quickstart

  • SELECT $1

Querying

  • SELECT * FROM users WHERE email = ?
  • SELECT * FROM users WHERE email = ? OR name = ?

Compile-time verification

  • SELECT country, COUNT(*) as count FROM users GROUP BY country WHERE organization = ?

I'm using v0.4.2 and tried following these examples, and although it did compile the generated queries did not substitute the parameter placeholder for the bound value when using ?. It only worked (both when query and query_as as well as the macros) when using the $1 placeholders.

I'd be happy to submit a PR correcting the examples as soon as the correct usage is established.

@mehcode
Copy link
Member

mehcode commented Jan 1, 2021

It should be made more clear in the README but currently we do not make any changes to the SQL statement that you write. This means you must use the parameter syntax that is appropriate for your database:

  • ? MySql
  • $1 Postgres
  • @p1 MSSQL
  • ?1 SQLite

@mehcode
Copy link
Member

mehcode commented Jan 1, 2021

See #875 for a proposal to add a unified way of writing parameters.

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