Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Make excluded-datetime return integers for days too (#69915)

metamben8a93fb4fcd23
diff --git a/src/metabase/driver/common/parameters/dates.clj b/src/metabase/driver/common/parameters/dates.clj
index 2ed31743ee9..8f92d310390 100644
--- a/src/metabase/driver/common/parameters/dates.clj
+++ b/src/metabase/driver/common/parameters/dates.clj
@@ -198,7 +198,7 @@
{:parser (#'qp.parameters.dates/regex->parser qp.parameters.dates/date-exclude-regex [:unit :exclusions])
:filter (fn [{:keys [unit exclusions]} field-clause]
(let [unit (keyword unit)
- exclusions (map (partial #'qp.parameters.dates/excluded-datetime unit (t/local-date))
+ exclusions (map (partial #'qp.parameters.dates/excluded-datetime unit)
(str/split exclusions #"-"))]
(when (and (seq exclusions) (every? some? exclusions))
(into [:!= (with-temporal-unit-if-field field-clause (#'qp.parameters.dates/excluded-temporal-unit unit))]
diff --git a/src/metabase/query_processor/parameters/dates.clj b/src/metabase/query_processor/parameters/dates.clj
index c9b4dae1576..a69ff783100 100644
--- a/src/metabase/query_processor/parameters/dates.clj
+++ b/src/metabase/query_processor/parameters/dates.clj
@@ -8,6 +8,7 @@
[clojure.string :as str]
[java-time.api :as t]
[medley.core :as m]
+ [metabase.driver.common :as driver.common]
[metabase.lib.core :as lib]
[metabase.lib.schema.common :as lib.schema.common]
[metabase.lib.schema.expression :as lib.schema.expression]
@@ -302,18 +303,24 @@
i))
(catch NumberFormatException _)))
-(defn- excluded-datetime [unit date exclusion]
- (let [year (t/year date)]
- (case unit
- :hour (when-let [hour (parse-int-in-range exclusion 0 23)]
- (format "%sT%02d:00:00" date hour))
- :day (when-let [day (short-day->day exclusion)]
- (str (t/adjust date :next-or-same-day-of-week day)))
- :month (when-let [month (short-month->month exclusion)]
- (format "%s-%02d-01" year month))
- :quarter (when-let [quarter (parse-int-in-range exclusion 1 4)]
- (format "%s-%02d-01" year (inc (* 3 (dec quarter)))))
- nil)))
+(def ^:private day->index
+ "0-based index of each day keyword in the canonical week order (Monday=0 ... Sunday=6),
+ matching [[metabase.driver.common/days-of-week]]."
+ {:monday 0, :tuesday 1, :wednesday 2, :thursday 3, :friday 4, :saturday 5, :sunday 6})
+
+(defn- excluded-datetime
+ "Return a numeric value for an exclusion filter. For `:day` exclusions, computes the Metabase-convention
+ day-of-week number (1 = start-of-week, 7 = day before start-of-week)."
+ [unit exclusion]
+ (case unit
+ :hour (parse-int-in-range exclusion 0 23)
+ :day (when-let [day (short-day->day exclusion)]
+ (let [day-idx (day->index day)
+ sow-idx (driver.common/start-of-week->int)]
+ (inc (mod (- day-idx sow-idx) 7))))
+ :month (short-month->month exclusion)
+ :quarter (parse-int-in-range exclusion 1 4)
+ nil))
(def ^:private excluded-temporal-unit
{:hour :hour-of-day
@@ -383,7 +390,7 @@
{:parser (regex->parser date-exclude-regex [:unit :exclusions])
:filter (fn [{:keys [unit exclusions]} field-clause]
(let [unit (keyword unit)
- exclusions (map (partial excluded-datetime unit (t/local-date))
+ exclusions (map (partial excluded-datetime unit)
(str/split exclusions #"-"))]
(when (and (seq exclusions) (every? some? exclusions))
(apply lib/!= (with-temporal-unit-if-field field-clause (excluded-temporal-unit unit)) exclusions))))}])
diff --git a/test/metabase/driver/common/parameters/dates_test.clj b/test/metabase/driver/common/parameters/dates_test.clj
index 4cc8ff16ffc..dd5d9019d8b 100644
--- a/test/metabase/driver/common/parameters/dates_test.clj
+++ b/test/metabase/driver/common/parameters/dates_test.clj
@@ -1,8 +1,7 @@
(ns metabase.driver.common.parameters.dates-test
(:require
[clojure.test :refer :all]
- ^{:clj-kondo/ignore [:deprecated-namespace]} [metabase.driver.common.parameters.dates :as params.dates]
- [metabase.test :as mt]))
+ ^{:clj-kondo/ignore [:deprecated-namespace]} [metabase.driver.common.parameters.dates :as params.dates]))
(deftest ^:parallel date-string->filter-test
(testing "year and month"
@@ -89,51 +88,50 @@
:month]
(params.dates/date-string->filter "next7hours-from-13months" [:field "field" {:base-type :type/DateTime}]))))
(testing "exclusions"
- (mt/with-clock #t "2016-06-07T12:13:55Z"
- (testing "hours"
- (is (= [:!=
- [:field "field" {:base-type :type/DateTime, :temporal-unit :hour-of-day}]
- "2016-06-07T00:00:00"]
- (params.dates/date-string->filter "exclude-hours-0" [:field "field" {:base-type :type/DateTime}])))
- (is (= [:!=
- [:field "field" {:base-type :type/DateTime, :temporal-unit :hour-of-day}]
- "2016-06-07T00:00:00"
- "2016-06-07T23:00:00"]
- (params.dates/date-string->filter "exclude-hours-0-23" [:field "field" {:base-type :type/DateTime}])))
- (is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-hours-\""
- (params.dates/date-string->filter "exclude-hours-" [:field "field" {:base-type :type/DateTime}])))
- (is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-hours-24-3\""
- (params.dates/date-string->filter "exclude-hours-24-3" [:field "field" {:base-type :type/DateTime}]))))
- (testing "quarters"
- (is (= [:!=
- [:field "field" {:base-type :type/DateTime, :temporal-unit :quarter-of-year}]
- "2016-01-01"]
- (params.dates/date-string->filter "exclude-quarters-1" [:field "field" {:base-type :type/DateTime}])))
- (is (= [:!=
- [:field "field" {:base-type :type/DateTime, :temporal-unit :quarter-of-year}]
- "2016-04-01"
- "2016-07-01"
- "2016-10-01"]
- (params.dates/date-string->filter "exclude-quarters-2-3-4" [:field "field" {:base-type :type/DateTime}])))
- (is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-quarters-Q1\""
- (params.dates/date-string->filter "exclude-quarters-Q1" [:field "field" {:base-type :type/DateTime}]))))
- (testing "days"
- (is (= [:!=
- [:field "field" {:base-type :type/DateTime, :temporal-unit :day-of-week}]
- "2016-06-10"
- "2016-06-07"]
- (params.dates/date-string->filter "exclude-days-Fri-Tue" [:field "field" {:base-type :type/DateTime}])))
- (is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-days-Friday\""
- (params.dates/date-string->filter "exclude-days-Friday" [:field "field" {:base-type :type/DateTime}]))))
- (testing "months"
- (is (= [:!=
- [:field "field" {:base-type :type/DateTime, :temporal-unit :month-of-year}]
- "2016-12-01"
- "2016-04-01"
- "2016-09-01"]
- (params.dates/date-string->filter "exclude-months-Dec-Apr-Sep" [:field "field" {:base-type :type/DateTime}])))
- (is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-months-April\""
- (params.dates/date-string->filter "exclude-months-April" [:field "field" {:base-type :type/DateTime}]))))
- (testing "minutes"
- (is (thrown? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-minutes-15-30\""
- (params.dates/date-string->filter "exclude-minutes-15-30" [:field "field" {:base-type :type/DateTime}])))))))
+ (testing "hours"
+ (is (= [:!=
+ [:field "field" {:base-type :type/DateTime, :temporal-unit :hour-of-day}]
+ 0]
+ (params.dates/date-string->filter "exclude-hours-0" [:field "field" {:base-type :type/DateTime}])))
+ (is (= [:!=
+ [:field "field" {:base-type :type/DateTime, :temporal-unit :hour-of-day}]
+ 0
+ 23]
+ (params.dates/date-string->filter "exclude-hours-0-23" [:field "field" {:base-type :type/DateTime}])))
+ (is (thrown-with-msg? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-hours-\""
+ (params.dates/date-string->filter "exclude-hours-" [:field "field" {:base-type :type/DateTime}])))
+ (is (thrown-with-msg? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-hours-24-3\""
+ (params.dates/date-string->filter "exclude-hours-24-3" [:field "field" {:base-type :type/DateTime}]))))
+ (testing "quarters"
+ (is (= [:!=
+ [:field "field" {:base-type :type/DateTime, :temporal-unit :quarter-of-year}]
+ 1]
+ (params.dates/date-string->filter "exclude-quarters-1" [:field "field" {:base-type :type/DateTime}])))
+ (is (= [:!=
+ [:field "field" {:base-type :type/DateTime, :temporal-unit :quarter-of-year}]
+ 2
+ 3
+ 4]
+ (params.dates/date-string->filter "exclude-quarters-2-3-4" [:field "field" {:base-type :type/DateTime}])))
+ (is (thrown-with-msg? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-quarters-Q1\""
+ (params.dates/date-string->filter "exclude-quarters-Q1" [:field "field" {:base-type :type/DateTime}]))))
+ (testing "days (with default start-of-week = Sunday: Sun=1, Mon=2, Tue=3, Wed=4, Thu=5, Fri=6, Sat=7)"
+ (is (= [:!=
+ [:field "field" {:base-type :type/DateTime, :temporal-unit :day-of-week}]
+ 6
+ 3]
+ (params.dates/date-string->filter "exclude-days-Fri-Tue" [:field "field" {:base-type :type/DateTime}])))
+ (is (thrown-with-msg? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-days-Friday\""
+ (params.dates/date-string->filter "exclude-days-Friday" [:field "field" {:base-type :type/DateTime}]))))
+ (testing "months"
+ (is (= [:!=
+ [:field "field" {:base-type :type/DateTime, :temporal-unit :month-of-year}]
+ 12
+ 4
+ 9]
+ (params.dates/date-string->filter "exclude-months-Dec-Apr-Sep" [:field "field" {:base-type :type/DateTime}])))
+ (is (thrown-with-msg? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-months-April\""
+ (params.dates/date-string->filter "exclude-months-April" [:field "field" {:base-type :type/DateTime}]))))
+ (testing "minutes"
+ (is (thrown-with-msg? clojure.lang.ExceptionInfo #"Don't know how to parse date string \"exclude-minutes-15-30\""
+ (params.dates/date-string->filter "exclude-minutes-15-30" [:field "field" {:base-type :type/DateTime}]))))))
diff --git a/test/metabase/driver/sql/parameters/substitute_test.clj b/test/metabase/driver/sql/parameters/substitute_test.clj
index cb3ed619453..a9ad8854baa 100644
--- a/test/metabase/driver/sql/parameters/substitute_test.clj
+++ b/test/metabase/driver/sql/parameters/substitute_test.clj
@@ -832,11 +832,7 @@
" month"
" from"
" \"PUBLIC\".\"CHECKINS\".\"DATE\""
- " ) <> extract("
- " month"
- " from"
- " ?"
- " )"
+ " ) <> 1"
" )"
" OR ("
" extract("
@@ -846,7 +842,7 @@
" ) IS NULL"
" )"
" );"]
- :params [#t "2016-01-01"]}
+ :params []}
(-> (expand-with-field-filter-param {:type :date/all-options, :value "exclude-months-Jan"})
(update :query #(str/split-lines (driver/prettify-native-form :h2 %))))))))))
@@ -866,11 +862,7 @@
" month"
" from"
" \"PUBLIC\".\"CHECKINS\".\"DATE\""
- " ) <> extract("
- " month"
- " from"
- " ?"
- " )"
+ " ) <> 1"
" )"
" OR ("
" extract("
@@ -886,11 +878,7 @@
" month"
" from"
" \"PUBLIC\".\"CHECKINS\".\"DATE\""
- " ) <> extract("
- " month"
- " from"
- " ?"
- " )"
+ " ) <> 2"
" )"
" OR ("
" extract("
@@ -901,8 +889,7 @@
" )"
" )"
" );"]
- :params [#t "2016-01-01"
- #t "2016-02-01"]}
+ :params []}
(-> (expand-with-field-filter-param {:type :date/all-options, :value "exclude-months-Jan-Feb"})
(update :query #(str/split-lines (driver/prettify-native-form :h2 %))))))))))
diff --git a/test/metabase/query_processor/dashboard_test.clj b/test/metabase/query_processor/dashboard_test.clj
index 5d13d3987d0..66d8d58313c 100644
--- a/test/metabase/query_processor/dashboard_test.clj
+++ b/test/metabase/query_processor/dashboard_test.clj
@@ -5,6 +5,9 @@
(:require
[clojure.test :refer :all]
[metabase.dashboards-rest.api-test :as api.dashboard-test]
+ [metabase.driver.common :as driver.common]
+ [metabase.lib.core :as lib]
+ [metabase.lib.metadata :as lib.metadata]
[metabase.query-processor :as qp]
[metabase.query-processor.card-test :as qp.card-test]
[metabase.query-processor.dashboard :as qp.dashboard]
@@ -464,3 +467,55 @@
(mt/with-temporary-setting-values [synchronous-batch-updates true]
(run-query-for-dashcard dashboard-id card-id dashcard-id)
(is (not= original-last-viewed-at (t2/select-one-fn :last_viewed_at :model/Dashboard :id dashboard-id)))))))))
+
+(deftest exclude-day-of-week-dashboard-parameter-test
+ (testing "Exclude day-of-week filter via dashboard parameter should not embed date literals in SQL (#68479)"
+ ;; Repro scenario from the issue:
+ ;; 1. Create a question on a table with a timestamp column
+ ;; 2. Add the question to a dashboard with a Date filter parameter
+ ;; 3. Set the filter to "Exclude Monday"
+ ;; 4. The dashboard query should produce the same results as running the question
+ ;; directly with an equivalent day-of-week filter.
+ ;;
+ ;; The underlying bug: the dashboard parameter path converts "exclude-days-Mon" into
+ ;; a date string value (e.g. "2026-02-23", a Monday) instead of a numeric day-of-week
+ ;; constant (e.g. 1). This causes the generated SQL to extract day-of-week from a date
+ ;; literal (on Postgres: extract(dow from CAST('2026-02-23' AS timestamp))) instead of
+ ;; comparing directly with a number (<> 1).
+ ;; This breaks on databases that can't handle the CAST (e.g. Cube.js).
+ (let [mp (mt/metadata-provider)
+ orders (lib.metadata/table mp (mt/id :orders))
+ created-at (lib.metadata/field mp (mt/id :orders :created_at))
+ base-query (-> (lib/query mp orders)
+ (lib/aggregate (lib/count)))]
+ (mt/with-temp [:model/Card {card-id :id} {:dataset_query base-query}
+ :model/Dashboard {dashboard-id :id} {:parameters [{:id "date_param"
+ :name "Date"
+ :slug "date"
+ :type "date/all-options"}]}
+ :model/DashboardCard {dashcard-id :id} {:dashboard_id dashboard-id
+ :card_id card-id
+ :parameter_mappings [{:parameter_id "date_param"
+ :card_id card-id
+ :target [:dimension
+ [:field (:id created-at) nil]]}]}]
+ (let [dashboard-result (run-query-for-dashcard
+ dashboard-id card-id dashcard-id
+ :parameters [{:id "date_param"
+ :value "exclude-days-Mon"}])
+ dashboard-sql (-> dashboard-result :data :native_form :query)
+ ;; Monday = index 0 in driver.common/days-of-week [:monday :tuesday ... :sunday]
+ ;; start-of-week->int returns 0-based index in that same vector (default :sunday = 6)
+ ;; Metabase day-of-week convention: 1 = start-of-week day, 7 = day before start-of-week
+ monday-dow (inc (mod (- (driver.common/start-of-week->int)) 7))
+ direct-result (qp/process-query
+ (-> base-query
+ (lib/filter (lib/!= (lib/with-temporal-bucket created-at :day-of-week) monday-dow))))]
+ (testing "Both queries return the same count"
+ (is (= (mt/rows direct-result)
+ (mt/rows dashboard-result))))
+ (testing "Dashboard SQL should not contain a date/timestamp literal in the WHERE clause"
+ ;; The dashboard parameter path currently embeds a date literal like
+ ;; '2026-02-23 00:00:00' and extracts day-of-week from it, rather than
+ ;; comparing with a numeric constant directly.
+ (is (not (re-find #"'\d{4}-\d{2}-\d{2}" dashboard-sql)))))))))
diff --git a/test/metabase/query_processor/parameters/dates_test.clj b/test/metabase/query_processor/parameters/dates_test.clj
index e755de2a5d6..4e1ff5b50d0 100644
--- a/test/metabase/query_processor/parameters/dates_test.clj
+++ b/test/metabase/query_processor/parameters/dates_test.clj
@@ -191,112 +191,107 @@
(deftest ^:parallel date-string->filter-test-15a
(testing "exclusions"
- (mt/with-clock #t "2016-06-07T12:13:55Z"
- (testing "hours"
- (is (=? [:!=
- {}
- [:field {:base-type :type/DateTime, :temporal-unit :hour-of-day} "field"]
- "2016-06-07T00:00:00"]
- (params.dates/date-string->filter
- "exclude-hours-0"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (=? [:!=
- {}
- [:field {:base-type :type/DateTime, :temporal-unit :hour-of-day} "field"]
- "2016-06-07T00:00:00"
- "2016-06-07T23:00:00"]
- (params.dates/date-string->filter
- "exclude-hours-0-23"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (thrown-with-msg?
- clojure.lang.ExceptionInfo
- #"Don't know how to parse date string \"exclude-hours-\""
- (params.dates/date-string->filter
- "exclude-hours-"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (thrown-with-msg?
- clojure.lang.ExceptionInfo
- #"Don't know how to parse date string \"exclude-hours-24-3\""
- (params.dates/date-string->filter
- "exclude-hours-24-3"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))))))
+ (testing "hours"
+ (is (=? [:!=
+ {}
+ [:field {:base-type :type/DateTime, :temporal-unit :hour-of-day} "field"]
+ 0]
+ (params.dates/date-string->filter
+ "exclude-hours-0"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (=? [:!=
+ {}
+ [:field {:base-type :type/DateTime, :temporal-unit :hour-of-day} "field"]
+ 0
+ 23]
+ (params.dates/date-string->filter
+ "exclude-hours-0-23"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Don't know how to parse date string \"exclude-hours-\""
+ (params.dates/date-string->filter
+ "exclude-hours-"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Don't know how to parse date string \"exclude-hours-24-3\""
+ (params.dates/date-string->filter
+ "exclude-hours-24-3"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"]))))))
(deftest ^:parallel date-string->filter-test-15b
(testing "exclusions"
- (mt/with-clock #t "2016-06-07T12:13:55Z"
- (testing "quarters"
- (is (=? [:!=
- {}
- [:field {:base-type :type/DateTime, :temporal-unit :quarter-of-year} "field"]
- "2016-01-01"]
- (params.dates/date-string->filter
- "exclude-quarters-1"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (=? [:!=
- {}
- [:field {:base-type :type/DateTime, :temporal-unit :quarter-of-year} "field"]
- "2016-04-01"
- "2016-07-01"
- "2016-10-01"]
- (params.dates/date-string->filter
- "exclude-quarters-2-3-4"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (thrown-with-msg?
- clojure.lang.ExceptionInfo
- #"Don't know how to parse date string \"exclude-quarters-Q1\""
- (params.dates/date-string->filter
- "exclude-quarters-Q1"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))))))
+ (testing "quarters"
+ (is (=? [:!=
+ {}
+ [:field {:base-type :type/DateTime, :temporal-unit :quarter-of-year} "field"]
+ 1]
+ (params.dates/date-string->filter
+ "exclude-quarters-1"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (=? [:!=
+ {}
+ [:field {:base-type :type/DateTime, :temporal-unit :quarter-of-year} "field"]
+ 2
+ 3
+ 4]
+ (params.dates/date-string->filter
+ "exclude-quarters-2-3-4"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Don't know how to parse date string \"exclude-quarters-Q1\""
+ (params.dates/date-string->filter
+ "exclude-quarters-Q1"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"]))))))
(deftest ^:parallel date-string->filter-test-15c
(testing "exclusions"
- (mt/with-clock #t "2016-06-07T12:13:55Z"
- (testing "days"
- (is (=? [:!=
- {}
- [:field {:base-type :type/DateTime, :temporal-unit :day-of-week} "field"]
- "2016-06-10"
- "2016-06-07"]
- (params.dates/date-string->filter
- "exclude-days-Fri-Tue"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (thrown-with-msg?
- clojure.lang.ExceptionInfo
- #"Don't know how to parse date string \"exclude-days-Friday\""
- (params.dates/date-string->filter
- "exclude-days-Friday"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))))))
+ (testing "days (with default start-of-week = Sunday: Sun=1, Mon=2, Tue=3, Wed=4, Thu=5, Fri=6, Sat=7)"
+ (is (=? [:!=
+ {}
+ [:field {:base-type :type/DateTime, :temporal-unit :day-of-week} "field"]
+ 6
+ 3]
+ (params.dates/date-string->filter
+ "exclude-days-Fri-Tue"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Don't know how to parse date string \"exclude-days-Friday\""
+ (params.dates/date-string->filter
+ "exclude-days-Friday"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"]))))))
(deftest ^:parallel date-string->filter-test-15d
(testing "exclusions"
- (mt/with-clock #t "2016-06-07T12:13:55Z"
- (testing "months"
- (is (=? [:!=
- {}
- [:field {:base-type :type/DateTime, :temporal-unit :month-of-year} "field"]
- "2016-12-01"
- "2016-04-01"
- "2016-09-01"]
- (params.dates/date-string->filter
- "exclude-months-Dec-Apr-Sep"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
- (is (thrown-with-msg?
- clojure.lang.ExceptionInfo
- #"Don't know how to parse date string \"exclude-months-April\""
- (params.dates/date-string->filter
- "exclude-months-April"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))))))
+ (testing "months"
+ (is (=? [:!=
+ {}
+ [:field {:base-type :type/DateTime, :temporal-unit :month-of-year} "field"]
+ 12
+ 4
+ 9]
+ (params.dates/date-string->filter
+ "exclude-months-Dec-Apr-Sep"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Don't know how to parse date string \"exclude-months-April\""
+ (params.dates/date-string->filter
+ "exclude-months-April"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"]))))))
(deftest ^:parallel date-string->filter-test-15e
(testing "exclusions"
- (mt/with-clock #t "2016-06-07T12:13:55Z"
- (testing "minutes"
- (is (thrown-with-msg?
- clojure.lang.ExceptionInfo
- #"Don't know how to parse date string \"exclude-minutes-15-30\""
- (params.dates/date-string->filter
- "exclude-minutes-15-30"
- [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"])))))))
+ (testing "minutes"
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Don't know how to parse date string \"exclude-minutes-15-30\""
+ (params.dates/date-string->filter
+ "exclude-minutes-15-30"
+ [:field {:lib/uuid "00000000-0000-0000-0000-000000000000", :base-type :type/DateTime} "field"]))))))
(defn do-date-string-range-test
[s->expected]