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
Use explicit hierarchy for temporal literal classes (#79461)
Ben Grabowb7322989e39b
diff --git a/src/metabase/query_processor/middleware/wrap_value_literals.clj b/src/metabase/query_processor/middleware/wrap_value_literals.cljindex e281c2ce350..bf7dc5bcd54 100644--- a/src/metabase/query_processor/middleware/wrap_value_literals.clj+++ b/src/metabase/query_processor/middleware/wrap_value_literals.clj@@ -47,12 +47,26 @@;; TODO -- parsing the temporal string literals should be moved into `auto-parse-filter-values`, it's really a;; separate transformation from just wrapping the value+(defonce ^{:private true+ :doc "Hierarchy grouping the java.time classes that share an [[add-type-info]] method. Kept separate from+ Clojure's global hierarchy so that these class registrations cannot collide with other users of the global+ hierarchy."}+ hierarchy+ (make-hierarchy))++(defn- derive!+ "Make `parent` an ancestor of `tag` in the temporal-class [[hierarchy]]."+ [tag parent]+ (alter-var-root #'hierarchy derive tag parent)+ nil)+(defmulti ^:private add-type-info"Wraps value literals in `:value` clauses that includes base type info about the Field they're being compared againstfor easy driver QP implementation. Temporal literals (e.g., ISO-8601 strings) get wrapped in `:time` or`:absolute-datetime` instead which includes unit as well; temporal strings get parsed and converted to "{:arglists '([x info & {:keys [parse-datetime-strings?]}])}- (fn [x & _] (class x)))+ (fn [x & _] (class x))+ :hierarchy #'hierarchy)(defmethod add-type-info nil[_ info & _]@@ -62,10 +76,10 @@[this info & _](lib/value info this))-(derive LocalDate ::->absolute-datetime)-(derive LocalDateTime ::->absolute-datetime)-(derive OffsetDateTime ::->absolute-datetime)-(derive ZonedDateTime ::->absolute-datetime)+(derive! LocalDate ::->absolute-datetime)+(derive! LocalDateTime ::->absolute-datetime)+(derive! OffsetDateTime ::->absolute-datetime)+(derive! ZonedDateTime ::->absolute-datetime)(prefer-method add-type-info ::->absolute-datetime Object)@@ -73,8 +87,8 @@[this info & _](lib/absolute-datetime this (get info :unit :default)))-(derive LocalTime ::->time)-(derive OffsetTime ::->time)+(derive! LocalTime ::->time)+(derive! OffsetTime ::->time)(prefer-method add-type-info ::->time Object)