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

Conversation

OrionNebula
Copy link

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:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided so that we can include it in CHANGELOG later

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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);
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

@@ -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.

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

Successfully merging this pull request may close these issues.

4 participants