Skip to content
Snippets Groups Projects
Unverified Commit 42b48cb6 authored by metamben's avatar metamben Committed by GitHub
Browse files

Return “contains” and “does-not-contain” for comment/description (#37900)

Fixes #36856.
parent 26e5ab5f
Branches
Tags
No related merge requests found
......@@ -76,10 +76,10 @@
{:name label
:filter (operator op field-ref value)})
(lib.types.isa/string? column)
(for [[op label] [[:= "="]
[:!= "≠"]
[:contains "contains"]
(and (lib.types.isa/string? column)
(or (lib.types.isa/comment? column)
(lib.types.isa/description? column)))
(for [[op label] [[:contains "contains"]
[:does-not-contain "does-not-contain"]]]
{:name label
:filter (operator op field-ref value)})
......
......@@ -182,16 +182,14 @@
(lib/available-drill-thrus query -1 context))]
(is (=? {:lib/type :metabase.lib.drill-thru/drill-thru
:type :drill-thru/quick-filter
:operators [{:name "="}
{:name "≠"}
{:name "contains"}
:operators [{:name "contains"}
{:name "does-not-contain"}]
:value "text"
:column {:name "BODY"}}
drill))
(testing "Should include :value in the display info (#33560)"
(is (=? {:type :drill-thru/quick-filter
:operators ["=" "≠" "contains" "does-not-contain"]
:operators ["contains" "does-not-contain"]
:value "text"}
(lib/display-info query drill))))
(testing "apply drills"
......
......@@ -44,7 +44,7 @@
[:created-at "2018-05-15T08:04:04.58Z"]
[:quantity 3]]))
(def ^:private products-query
(def ^:private products-query
(lib/query meta/metadata-provider (meta/table-metadata :products)))
(def ^:private products-row
......@@ -58,6 +58,18 @@
[:rating 3.5]
[:created-at "2016-10-19T12:34:56.789Z"]]))
(def ^:private reviews-query
(lib/query meta/metadata-provider (meta/table-metadata :reviews)))
(def ^:private reviews-row
(row-for :reviews
[[:id 4]
[:product-id 1]
[:reviewer "barbara-shields"]
[:rating 4]
[:body "lorem ipsum"]
[:created-at "2023-11-13T10:29:43.394Z"]]))
(defn- drill-thru-test-args [drill]
(case (:type drill)
;; filter-op value
......@@ -281,9 +293,7 @@
{:lib/type :metabase.lib.drill-thru/drill-thru
:type :drill-thru/quick-filter
:operators (for [[op label] [[:= "="]
[:!= "≠"]
[:contains "contains"]
[:does-not-contain "does-not-contain"]]]
[:!= "≠"]]]
{:name label
:filter [op {:lib/uuid string?}
[:field {:lib/uuid string?} (meta/id :products :category)]
......@@ -304,9 +314,7 @@
{:lib/type :metabase.lib.drill-thru/drill-thru
:type :drill-thru/quick-filter
:operators (for [[op label] [[:= "="]
[:!= "≠"]
[:contains "contains"]
[:does-not-contain "does-not-contain"]]]
[:!= "≠"]]]
{:name label
:filter [op {:lib/uuid string?}
[:field {:lib/uuid string?} (meta/id :products :vendor)]
......@@ -314,6 +322,27 @@
(lib/available-drill-thrus products-query -1 context)))
(test-drill-applications products-query context)))))
(deftest ^:parallel table-view-available-drill-thrus-description-value-test
(testing "table values: click on"
(testing "description value - filter contains, does-not-contain, and object details *for the PK column*"
(let [context (merge (basic-context (meta/field-metadata :reviews :body) "lorem ipsum")
{:row reviews-row})]
(is (=? [{:lib/type :metabase.lib.drill-thru/drill-thru
:type :drill-thru/zoom
:column (meta/field-metadata :reviews :id) ; It should correctly find the PK column
:object-id (-> reviews-row first :value) ; And its value
:many-pks? false}
{:lib/type :metabase.lib.drill-thru/drill-thru
:type :drill-thru/quick-filter
:operators (for [[op label] [[:contains "contains"]
[:does-not-contain "does-not-contain"]]]
{:name label
:filter [op {:lib/uuid string?}
[:field {:lib/uuid string?} (meta/id :reviews :body)]
"lorem ipsum"]})}]
(lib/available-drill-thrus reviews-query -1 context)))
(test-drill-applications reviews-query context)))))
(deftest ^:parallel table-view-available-drill-thrus-null-value-test
(testing "table values: click on"
(testing "NULL value - basic quick filters and object details *for the PK column*"
......
......@@ -2058,7 +2058,7 @@
[_table-name _field-name]
{:description nil
:database-type "CHARACTER VARYING"
:semantic-type nil
:semantic-type :type/Description
:table-id (id :reviews)
:coercion-strategy nil
:name "BODY"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment