Skip to content
Snippets Groups Projects
Unverified Commit 6a5efe5e authored by Tim Macdonald's avatar Tim Macdonald Committed by GitHub
Browse files

Native Query Analyzer cleanup (#41950)

* Missing sentence for NQA documentation

* Add a test for optional field filter parsing
parent 25550753
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,8 @@
2. Contain Metabase-specific business logic.
The primary way of interacting with parsed queries is through their associated QueryFields (see model
file). QueryFields are maintained through the `update-query-fields-for-card!` function.
file). QueryFields are maintained through the `update-query-fields-for-card!` function. This is invoked as part of
the lifecycle of a card (see Card model).
Query rewriting happens with the `replace-names` function."
(:require
......
......@@ -166,6 +166,11 @@
(->sql (mt/native-query {:template-tags (tags "num_between")
:query "SELECT * FROM orders WHERE {{num_between}}"})))))
(deftest optional-field-filter-test
(is (= "SELECT * FROM orders WHERE \"PUBLIC\".\"ORDERS\".\"TOTAL\" BETWEEN 1 AND 2 AND (\"PUBLIC\".\"ORDERS\".\"TOTAL\" = 1)"
(->sql (mt/native-query {:template-tags (tags "num_between" "num_eq")
:query "SELECT * FROM orders WHERE {{num_between}} [[AND {{num_eq}}]]"})))))
(deftest field-filter-string-test
(is (= "SELECT * FROM people WHERE ((\"PUBLIC\".\"PEOPLE\".\"NAME\" <> ?) OR (\"PUBLIC\".\"PEOPLE\".\"NAME\" IS NULL))"
(->sql (mt/native-query {:template-tags (tags "str_not_eq")
......
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