Skip to content
Snippets Groups Projects
Unverified Commit 6eb21346 authored by Braden Shepherdson's avatar Braden Shepherdson Committed by GitHub
Browse files

[QP] Fix error with `:!=` "Is Not" filter on expression (#42461)

parent 6864bc7e
No related branches found
No related tags found
No related merge requests found
...@@ -1254,7 +1254,8 @@ ...@@ -1254,7 +1254,8 @@
(defn- correct-null-behaviour (defn- correct-null-behaviour
[driver [op & args :as clause]] [driver [op & args :as clause]]
(if-let [field-arg (lib.util.match/match-one args (if-let [field-arg (lib.util.match/match-one args
:field &match)] :field &match
:expression &match)]
;; We must not transform the head again else we'll have an infinite loop ;; We must not transform the head again else we'll have an infinite loop
;; (and we can't do it at the call-site as then it will be harder to fish out field references) ;; (and we can't do it at the call-site as then it will be harder to fish out field references)
[:or [:or
......
...@@ -274,6 +274,7 @@ ...@@ -274,6 +274,7 @@
:type :query :type :query
:query (merge :query (merge
{:source-query {:native "select 'foo' as a union select null as a union select 'bar' as a"} {:source-query {:native "select 'foo' as a union select null as a union select 'bar' as a"}
:expressions {"initial" [:regex-match-first [:field "A" {:base-type :type/Text}] "(\\w)"]}
:order-by [[:asc [:field "A" {:base-type :type/Text}]]]} :order-by [[:asc [:field "A" {:base-type :type/Text}]]]}
query)}))) query)})))
...@@ -287,7 +288,9 @@ ...@@ -287,7 +288,9 @@
(is (= [[nil] ["bar"]] (is (= [[nil] ["bar"]]
(query-on-dataset-with-nils {:filter [:not [:contains [:field "A" {:base-type :type/Text}] "f"]]}))) (query-on-dataset-with-nils {:filter [:not [:contains [:field "A" {:base-type :type/Text}] "f"]]})))
(is (= [[nil] ["bar"]] (is (= [[nil] ["bar"]]
(query-on-dataset-with-nils {:filter [:!= [:field "A" {:base-type :type/Text}] "foo"]})))) (query-on-dataset-with-nils {:filter [:!= [:field "A" {:base-type :type/Text}] "foo"]})))
(is (= [[nil] ["bar"]]
(query-on-dataset-with-nils {:filter [:!= [:expression "initial" {:base-type :type/Text}] "f"]}))))
(testing "Null behaviour correction fix should work with joined fields (#13534)" (testing "Null behaviour correction fix should work with joined fields (#13534)"
(is (= [[1000]] (is (= [[1000]]
(mt/rows (mt/rows
......
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