Skip to content
Snippets Groups Projects
Commit 9bbbca65 authored by Cam Saül's avatar Cam Saül Committed by GitHub
Browse files

Merge pull request #4096 from metabase/minor-cleanup-2017

Use new driver/format-custom-field-name method in tests [ci drivers]
parents 3ec9536c 82bb7109
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@
:is_active true
:definition {:clause ["a" "b"]}}
(tu/with-temp* [Database [{database-id :id}]
Table [{:keys [id]} {:db_id database-id}]]
Table [{:keys [id]} {:db_id database-id}]]
(create-metric-then-select! id "I only want *these* things" nil (user->id :rasta) {:clause ["a" "b"]})))
......@@ -49,12 +49,12 @@
[true
false]
(tu/with-temp* [Database [{database-id :id}]
Table [{table-id :id} {:db_id database-id}]
Metric [{metric-id :id} {:table_id table-id
:definition {:database 45
:query {:filter ["yay"]}}}]]
Table [{table-id :id} {:db_id database-id}]
Metric [{metric-id :id} {:table_id table-id
:definition {:database 45
:query {:filter ["yay"]}}}]]
[(metric/exists? metric-id)
(metric/exists? 34)]))
(metric/exists? Integer/MAX_VALUE)])) ; a Metric that definitely doesn't exist
;; retrieve-metric
......@@ -71,10 +71,10 @@
:definition {:database 45
:query {:filter ["yay"]}}}
(tu/with-temp* [Database [{database-id :id}]
Table [{table-id :id} {:db_id database-id}]
Metric [{metric-id :id} {:table_id table-id
:definition {:database 45
:query {:filter ["yay"]}}}]]
Table [{table-id :id} {:db_id database-id}]
Metric [{metric-id :id} {:table_id table-id
:definition {:database 45
:query {:filter ["yay"]}}}]]
(let [{:keys [creator] :as metric} (retrieve-metric metric-id)]
(update (dissoc metric :id :table_id :created_at :updated_at)
:creator (u/rpartial dissoc :date_joined :last_login)))))
......
(ns metabase.query-processor-test.expression-aggregations-test
"Tests for expression aggregations and for named aggregations."
(:require [expectations :refer :all]
[metabase.driver :as driver]
[metabase.models.metric :refer [Metric]]
[metabase.query-processor :as qp]
[metabase.query-processor.expand :as ql]
[metabase.query-processor-test :refer :all]
[metabase.test.data :as data]
[metabase.test.data.datasets :as datasets, :refer [*engine*]]
[metabase.test.data.datasets :as datasets, :refer [*engine* *driver*]]
[metabase.test.util :as tu]
[metabase.util :as u]))
......@@ -167,7 +168,7 @@
[3 52]
[4 30]]
:columns [(data/format-name "price")
(if (= *engine* :redshift) "new price" "New Price")]} ; Redshift annoyingly always lowercases column aliases
(driver/format-custom-field-name *driver* "New Price")]} ; Redshift annoyingly always lowercases column aliases
(format-rows-by [int int]
(rows+column-names (data/run-query venues
(ql/aggregation (ql/named (ql/sum (ql/+ $price 1)) "New Price"))
......@@ -180,7 +181,7 @@
[3 -2]
[4 -17]]
:columns [(data/format-name "price")
(if (= *engine* :redshift) "sum-41" "Sum-41")]}
(driver/format-custom-field-name *driver* "Sum-41")]}
(format-rows-by [int int]
(rows+column-names (data/run-query venues
(ql/aggregation (ql/named (ql/- (ql/sum $price) 41) "Sum-41"))
......@@ -208,7 +209,7 @@
[3 39]
[4 24]]
:columns [(data/format-name "price")
(if (= *engine* :redshift) "my cool metric" "My Cool Metric")]}
(driver/format-custom-field-name *driver* "My Cool Metric")]}
(tu/with-temp Metric [metric {:table_id (data/id :venues)
:definition {:aggregation [:sum [:field-id (data/id :venues :price)]]
:filter [:> [:field-id (data/id :venues :price)] 1]}}]
......@@ -226,7 +227,7 @@
[3 39]
[4 24]]
:columns [(data/format-name "price")
(if (= *engine* :redshift) "my cool metric" "My Cool Metric")]}
(driver/format-custom-field-name *driver* "My Cool Metric")]}
(tu/with-temp Metric [metric {:table_id (data/id :venues)
:definition {:aggregation [[:sum [:field-id (data/id :venues :price)]]]
:filter [:> [:field-id (data/id :venues :price)] 1]}}]
......@@ -240,7 +241,7 @@
;; check that named aggregations come back with the correct column metadata (#4002)
(datasets/expect-with-engines (engines-that-support :expression-aggregations)
(let [col-name (if (= *engine* :redshift) "count of things" "Count of Things")]
(let [col-name (driver/format-custom-field-name *driver* "Count of Things")]
(assoc (aggregate-col :count)
:name col-name
:display_name col-name))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment