Skip to content

Commit

Permalink
Merge pull request #16 from velimovich/master
Browse files Browse the repository at this point in the history
Add an ability to provide settings for a query
  • Loading branch information
PNixx authored Dec 3, 2019
2 parents e29bdea + 6ba28f6 commit 0f0bcdc
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f0bcdc

Please sign in to comment.