Skip to content
Snippets Groups Projects
Commit 0934a370 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #337 from metabase/ag-no-500-on-dataset

don't return a 500 response on dataset query failure
parents 455fb53a 1ccbfa3b
Branches
Tags
No related merge requests found
......@@ -11,9 +11,7 @@
"Execute an MQL query and retrieve the results as JSON."
[:as {{:keys [database] :as body} :body}]
(read-check Database database)
(let [{:keys [status] :as response} (driver/dataset-query body {:executed_by *current-user-id*})]
{:status (if (= status :completed) 200 500)
:body response}))
(driver/dataset-query body {:executed_by *current-user-id*}))
(defendpoint GET "/csv"
"Execute an MQL query and download the result data as a CSV file."
......
......@@ -24,3 +24,26 @@
:filter [nil nil]
:limit nil
:source_table (table->id :checkins)}}))
;; Even if a query fails we still expect a 200 response from the api
(expect-eval-actual-first
(match-$ (sel :one QueryExecution (order :id :desc))
{:data {:rows []
:cols []
:columns []}
:error "Syntax error in SQL statement \"FOOBAR[*] \"; expected \"FROM, {\""
:raw_query ""
:row_count 0
:result_rows 0
:status "failed"
:query_id nil
:version 0
:json_query $
:started_at $
:finished_at $
:running_time $
:id $
:uuid $})
((user->client :rasta) :post 200 "meta/dataset" {:database (:id @test-db)
:type "native"
:native {:query "foobar"}}))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment