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

Don't specify 'readonly' twice if it appears in the client's option list #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Query {
let use_post = !read_only || query.len() > MAX_QUERY_LEN_TO_USE_GET;

let (method, body, content_length) = if use_post {
if read_only {
if read_only && !self.client.options.contains_key("readonly") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if read-only=0 is provided? According to https://clickhouse.com/docs/en/operations/settings/permissions-for-queries#readonly, we must use POST for such queries, so it should also affect the use_post flag.

pairs.append_pair("readonly", "1");
}
let len = query.len();
Expand Down
10 changes: 10 additions & 0 deletions tests/it/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ async fn long_query() {
.unwrap();

assert_eq!(got_string, long_string);

let got_string = client
.query("select ?")
.bind(&long_string)
.with_option("readonly", "2")
.fetch_one::<String>()
.await
.unwrap();

assert_eq!(got_string, long_string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally assert would be that readonly came through as 2. Changing query to show readonly could have that effect

}

// See #22.
Expand Down
Loading