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

Problems with query SQL initiated when string is in single quotes: select * from log where query like '%\'event_a\'%' #96

Open
Doslin opened this issue Nov 28, 2023 · 0 comments

Comments

@Doslin
Copy link

Doslin commented Nov 28, 2023

clickhouse.rs version 0.11.6
rustc version 1.74.0

Problems with query SQL initiated when string is in single quotes

Reproducer:

use clickhouse::Row;
use std::error::Error;

#[derive(Row, Debug, serde::Deserialize)]
struct Res {
    result: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let client = clickhouse::Client::default().with_url("http://localhost:8123");

    let _: Vec<Res> = client
        .query(
            "SELECT query result FROM system.query_log where  query like '%\'event_a\'%' limit 1",
        )
        .fetch_all()
        .await?;

    Ok(())
}

Result:

> cargo run
warning: `query-tools` (example "test_con_ch") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 2.78s
     Running `target/debug/examples/test_con_ch`
Error: BadResponse("Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 64 ('event_a'): event_a'%' limit 1 FORMAT RowBinary\n. Expected one of: UNION, LIMIT, WINDOW, DoubleColon, LIKE, GLOBAL NOT IN, end of query, HAVING, AS, DIV, IS, GROUP BY, INTO OUTFILE, OR, QuestionMark, BETWEEN, OFFSET, NOT LIKE, MOD, AND, alias, ORDER BY, SETTINGS, IN, ILIKE, FORMAT, NOT ILIKE, WITH, NOT, token, NOT IN, GLOBAL IN (version 21.8.15.7)")
@slvrtrn slvrtrn added bug Something isn't working need-example and removed bug Something isn't working labels Jul 29, 2024
@slvrtrn slvrtrn mentioned this issue Jul 30, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants