The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Skip setting pivot defaults when no options are provided at all (#83052)
metamben806c8becba45
diff --git a/src/metabase/query_processor/middleware/pivot_export.clj b/src/metabase/query_processor/middleware/pivot_export.cljindex eb74babedb7..b77feb6b4d5 100644--- a/src/metabase/query_processor/middleware/pivot_export.clj+++ b/src/metabase/query_processor/middleware/pivot_export.clj@@ -11,11 +11,12 @@;; the `qp.si/streaming-results-writer` implmementations can apply/not-apply formatting based on the key's value(let [opts (get-in query [:middleware :pivot-options]);; Ensure we always have defaults for these settings- opts (-> opts- (update :show-row-totals (fnil identity true))- (update :show-column-totals (fnil identity true)))+ opts (when opts+ (-> opts+ (update :show-row-totals (fnil identity true))+ (update :show-column-totals (fnil identity true))))pivot (get-in query [:middleware :pivot?])metadata (cond-> metadataopts (assoc :pivot-export-options opts)- pivot (assoc :pivot? pivot))]+ (and pivot opts) (assoc :pivot? pivot))](rff metadata))))diff --git a/test/metabase/queries_rest/api/card_test.clj b/test/metabase/queries_rest/api/card_test.cljindex a892efb9b81..e3edcf7d1dd 100644--- a/test/metabase/queries_rest/api/card_test.clj+++ b/test/metabase/queries_rest/api/card_test.clj@@ -2547,6 +2547,16 @@(cond-> response(string? response) (-> u/strip-bom str/split-lines)))))))))+(deftest csv-download-pivot-results-on-non-pivot-card-test+ (testing "pivot_results is ignored on non-pivot cards (#81323)"+ (with-temp-native-card [_ card]+ (let [response (mt/user-http-request :crowberto :post 200 (format "card/%d/query/csv" (u/the-id card))+ {:pivot_results true})]+ (is (= ["COUNT(*)"+ "75"]+ (cond-> response+ (string? response) (-> u/strip-bom str/split-lines))))))))+(deftest json-download-test(testing "no parameters"(with-temp-native-card [_ card]