Skip to content
Snippets Groups Projects
Unverified Commit 2c69dc73 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by GitHub
Browse files

Fix X-Ray table field shown as "null" in the title (#18066)

Field were not normalized before being processed
resulting in the result being `null`

Fixes #15737
parent 3db89e2a
Branches
Tags
No related merge requests found
......@@ -111,7 +111,7 @@ describe("scenarios > x-rays", () => {
cy.get(".DashCard");
});
it.skip(`"${action.toUpperCase()}" should not show NULL in titles of generated dashboard cards (metabase#15737)`, () => {
it(`"${action.toUpperCase()}" should not show NULL in titles of generated dashboard cards (metabase#15737)`, () => {
cy.intercept("GET", "/api/automagic-dashboards/**").as("xray");
visitQuestionAdhoc({
name: "15737",
......
......@@ -1099,10 +1099,11 @@
(defn- field-reference->field
[root field-reference]
(let [temporal-unit (mbql.u/match-one (normalize/normalize field-reference)
[:field _ (opts :guard :temporal-unit)]
(:temporal-unit opts))]
(cond-> (->> field-reference
(let [normalized-field-reference (normalize/normalize field-reference)
temporal-unit (mbql.u/match-one normalized-field-reference
[:field _ (opts :guard :temporal-unit)]
(:temporal-unit opts))]
(cond-> (->> normalized-field-reference
filters/collect-field-references
first
(->field root))
......
......@@ -517,3 +517,27 @@
:iso-day-of-year :millisecond)]
(testing unit
(is (some? (#'magic/humanize-datetime "1990-09-09T12:30:00" unit)))))))
;;; ------------------- Cell titles -------------------
(deftest cell-title-test
(mt/$ids venues
(let [query (query/adhoc-query {:query {:source-table (mt/id :venues)
:aggregation [:count]}
:type :query
:database (mt/id)})
root (magic/->root query)]
(testing "Should humanize equal filter"
(is (= "number of Venues where Name is Test"
;; Test specifically the un-normalized form (metabase#15737)
(magic/cell-title root ["=" ["field" %name nil] "Test"]))))
(testing "Should humanize and filter"
(is (= "number of Venues where Name is Test and Price is 0"
(magic/cell-title root ["and"
["=" $name "Test"]
["=" $price 0]]))))
(testing "Should humanize between filter"
(is (= "number of Venues where Name is between A and J"
(magic/cell-title root ["between" $name "A", "J"]))))
(testing "Should humanize inside filter"
(is (= "number of Venues where Longitude is between 2 and 4; and Latitude is between 3 and 1"
(magic/cell-title root ["inside" (mt/$ids venues $latitude) (mt/$ids venues $longitude) 1 2 3 4])))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment