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

Interpret ? as a parameter only if .bind was called at least once #157

Open
slvrtrn opened this issue Sep 23, 2024 · 1 comment
Open

Interpret ? as a parameter only if .bind was called at least once #157

slvrtrn opened this issue Sep 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@slvrtrn
Copy link
Contributor

slvrtrn commented Sep 23, 2024

Related to #154

Considering this query:

client
    .query("SELECT 1 FROM test WHERE a IN 'a?b'")
    .fetch_one::<u8>()
    .execute()
    .await?;

Currently, an unescaped ? is still considered a missing parameter; after the fix, the query should be written as:

client
    .query("SELECT 1 FROM test WHERE a IN 'a??b'")
    .fetch_one::<u8>()
    .execute()
    .await?;

This might be problematic if a query is pre-generated elsewhere (file, etc) and contains question marks, but we did not want to do any client-side binding.

@slvrtrn slvrtrn added the enhancement New feature or request label Sep 23, 2024
@loyd
Copy link
Collaborator

loyd commented Sep 24, 2024

The context: this crate uses custom parameters (implemented before CH started to support server-side parameters).
Now, server-side parameters can be used, as shown in #142 (comment) (not an ideal solution, but already possible). Users can use server-side parameters and don't realize that their queries can fail due to an extra ? in the query.

The idea here has a drawback: users will get an invalid query if they want to use ? but forget all .bind() calls. However, they will get a runtime error from CH in this case, so it's not a big difference.

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

No branches or pull requests

2 participants