-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Problem
When using the gem with read-only ClickHouse users, queries fail because read-only users don't have permission to use the send_progress_in_http_headers parameter. This happens because the parameter is always set when the body is not empty in the Connection#get method:
click_house/lib/click_house/connection.rb
Line 40 in 663b72d
| conn.params[:send_progress_in_http_headers] = 1 unless body.empty? |
Impact
This prevents using the gem with read-only ClickHouse users, as they receive permission errors when attempting to execute queries.
Suggested Solution
Make the send_progress_in_http_headers parameter configurable through the gem's configuration. This would maintain backward compatibility while allowing users to disable it when needed.
Implementation suggestion:
- Add a configuration option to
Configclass:
class Config
# ... existing attributes ...
attr_accessor :send_progress_in_http_headers
def initialize
# ... existing initialization ...
@send_progress_in_http_headers = true # Default to current behavior
end
end- Modify the
getmethod inConnectionclass:
def get(path = '/', body: '', query: {}, database: config.database)
# ... existing code ...
transport.get(path) do |conn|
conn.params = query.merge(database: database).compact
# Only set the parameter if configured to do so and body is not empty
if !body.empty? && config.send_progress_in_http_headers
conn.params[:send_progress_in_http_headers] = 1
end
conn.body = body
end
end- Users could then configure this option:
ClickHouse.config do |config|
# ... other configuration ...
config.send_progress_in_http_headers = false # Disable for read-only users
endThis approach would maintain backward compatibility while solving the issue for users working with read-only ClickHouse accounts.