Skip to content

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

Normalize parameter type category/= to category (#65158)

metamben6b098da5debd
diff --git a/src/metabase/lib/schema/parameter.cljc b/src/metabase/lib/schema/parameter.cljc
index cb25a123b38..6c318de7ec8 100644
--- a/src/metabase/lib/schema/parameter.cljc
+++ b/src/metabase/lib/schema/parameter.cljc
@@ -153,9 +153,10 @@
;; a lot of broken code in Actions was setting param types to invalid things like
;; `:type/Text`... fix it
(when-let [param-type (lib.schema.common/normalize-keyword param-type)]
- (if (= (namespace param-type) "type")
- (keyword (u/lower-case-en (name param-type)))
- param-type)))}]
+ (cond
+ (= (namespace param-type) "type") (keyword (u/lower-case-en (name param-type)))
+ (= param-type :category/=) :category
+ :else param-type)))}]
(keys types)))
(mr/def ::widget-type
diff --git a/test/metabase/lib/schema/parameter_test.cljc b/test/metabase/lib/schema/parameter_test.cljc
index 5464e723620..8ab142d00f5 100644
--- a/test/metabase/lib/schema/parameter_test.cljc
+++ b/test/metabase/lib/schema/parameter_test.cljc
@@ -77,9 +77,14 @@
(lib/normalize ::lib.schema.parameter/target [:template-tag "x"]))))
(deftest ^:parallel decode-busted-param-type-test
- (is (= :text
- (lib/normalize ::lib.schema.parameter/type "type/Text")
- (lib/normalize ::lib.schema.parameter/type :type/Text))))
+ (testing "type namespace should be removed"
+ (is (= :text
+ (lib/normalize ::lib.schema.parameter/type "type/Text")
+ (lib/normalize ::lib.schema.parameter/type :type/Text))))
+ (testing ":category/= should normalize to :category"
+ (is (= :category
+ (lib/normalize ::lib.schema.parameter/type "category/=")
+ (lib/normalize ::lib.schema.parameter/type :category/=)))))
(deftest ^:parallel default-to-type-text-test
(is (= {:id "x", :type :text}