-
Notifications
You must be signed in to change notification settings - Fork 102
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
base: main
Are you sure you want to change the base?
Conversation
Olivia Trewin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
.await | ||
.unwrap(); | ||
|
||
assert_eq!(got_string, long_string); |
There was a problem hiding this comment.
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
@@ -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") { |
There was a problem hiding this comment.
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.
Summary
If a user specifies the "readonly" option at the client level and tries to execute a query too long to fit in the GET request's query parameters, "readonly" is set twice in the header - once as "1" and again as whatever the user specified. In particular, this means it's not possible to set another value for "readonly" on queries that use the POST method. Bypass setting "readonly" the first time if it's part of the Client's options already.
Checklist
Delete items not relevant to your PR: