diff --git a/frontend/src/metabase/query_builder/components/DownloadWidget.jsx b/frontend/src/metabase/query_builder/components/DownloadWidget.jsx index bf0fb87cb2a7c908bceb13284d691251c69c6039..1ecef684daedaa5c42c2e11af0eb7ff1f2369be2 100644 --- a/frontend/src/metabase/query_builder/components/DownloadWidget.jsx +++ b/frontend/src/metabase/query_builder/components/DownloadWidget.jsx @@ -7,6 +7,8 @@ import DownloadButton from "metabase/components/DownloadButton.jsx"; import FieldSet from "metabase/components/FieldSet.jsx"; +import _ from "underscore"; + const DownloadWidget = ({ className, card, datasetQuery, isLarge }) => <PopoverWithTrigger triggerElement={<Icon className={className} title="Download this data" name='download' size={16} />} @@ -29,7 +31,8 @@ const DownloadWidget = ({ className, card, datasetQuery, isLarge }) => } params={card.id != null ? { parameters: JSON.stringify(datasetQuery.parameters) } : - { query: JSON.stringify(datasetQuery) } + // exclude `constraints` to ensure we download all rows (up to hard-coded 1M): + { query: JSON.stringify(_.omit(datasetQuery, "constraints")) } } extensions={[type]} > diff --git a/src/metabase/api/card.clj b/src/metabase/api/card.clj index d205feba259d27fe23b66617360b47a355886154..02ba3e9dfa2dc63a2dde0d3145884979ab995686 100644 --- a/src/metabase/api/card.clj +++ b/src/metabase/api/card.clj @@ -324,12 +324,12 @@ ;;; ------------------------------------------------------------ Running a Query ------------------------------------------------------------ -(defn- run-query-for-card [card-id parameters] +(defn- run-query-for-card [card-id parameters constraints] {:pre [(u/maybe? sequential? parameters)]} (let [card (read-check Card card-id) query (assoc (:dataset_query card) :parameters parameters - :constraints dataset-api/query-constraints) + :constraints constraints) options {:executed-by *current-user-id* :card-id card-id}] (qp/dataset-query query options))) @@ -337,19 +337,19 @@ (defendpoint POST "/:card-id/query" "Run the query associated with a Card." [card-id :as {{:keys [parameters]} :body}] - (run-query-for-card card-id parameters)) + (run-query-for-card card-id parameters dataset-api/query-constraints)) (defendpoint POST "/:card-id/query/csv" "Run the query associated with a Card, and return its results as CSV. Note that this expects the parameters as serialized JSON in the 'parameters' parameter" [card-id parameters] {parameters (s/maybe su/JSONString)} - (dataset-api/as-csv (run-query-for-card card-id (json/parse-string parameters keyword)))) + (dataset-api/as-csv (run-query-for-card card-id (json/parse-string parameters keyword) nil))) (defendpoint POST "/:card-id/query/json" "Run the query associated with a Card, and return its results as JSON. Note that this expects the parameters as serialized JSON in the 'parameters' parameter" [card-id parameters] {parameters (s/maybe su/JSONString)} - (dataset-api/as-json (run-query-for-card card-id (json/parse-string parameters keyword)))) + (dataset-api/as-json (run-query-for-card card-id (json/parse-string parameters keyword) nil))) (define-routes) diff --git a/src/metabase/api/dataset.clj b/src/metabase/api/dataset.clj index 42c7789c124eb657047527b80fcc82ce8c9c7815..9fc602ee412f4f90230cee28a86dd270a648c334 100644 --- a/src/metabase/api/dataset.clj +++ b/src/metabase/api/dataset.clj @@ -85,7 +85,7 @@ {query su/JSONString} (let [query (json/parse-string query keyword)] (read-check Database (:database query)) - (as-csv (qp/dataset-query query {:executed-by *current-user-id*})))) + (as-csv (qp/dataset-query (dissoc query :constraints) {:executed-by *current-user-id*})))) (defendpoint POST "/json" "Execute a query and download the result data as a JSON file." @@ -93,7 +93,7 @@ {query su/JSONString} (let [query (json/parse-string query keyword)] (read-check Database (:database query)) - (as-json (qp/dataset-query query {:executed-by *current-user-id*})))) + (as-json (qp/dataset-query (dissoc query :constraints) {:executed-by *current-user-id*})))) (define-routes)