diff --git a/lib/active_record/connection_adapters/clickhouse/schema_statements.rb b/lib/active_record/connection_adapters/clickhouse/schema_statements.rb index 64898012..a7a3e450 100644 --- a/lib/active_record/connection_adapters/clickhouse/schema_statements.rb +++ b/lib/active_record/connection_adapters/clickhouse/schema_statements.rb @@ -86,21 +86,22 @@ def do_system_execute(sql, name = nil) end end - private - - def apply_format(sql, format) - format ? "#{sql} FORMAT #{format}" : sql - end - - def do_execute(sql, name = nil, format: 'JSONCompact') + def do_execute(sql, name = nil, format: 'JSONCompact', settings: {}) log(sql, "#{adapter_name} #{name}") do formatted_sql = apply_format(sql, format) - res = @connection.post("/?#{@config.to_param}", formatted_sql) + request_params = @config || {} + res = @connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql) process_response(res) end end + private + + def apply_format(sql, format) + format ? "#{sql} FORMAT #{format}" : sql + end + def process_response(res) case res.code.to_i when 200