From c2c37135ca5f6a29b31e3ed190dc6f899a233d32 Mon Sep 17 00:00:00 2001 From: Robert Roland <rob@metabase.com> Date: Tue, 27 Oct 2020 10:17:31 -0700 Subject: [PATCH] [[null]] is a valid response (#13596) * Repro for #13571: Display rows whose value is `null` (#13591) [ci skip] * Reproduces #13571 Co-authored-by: flamber <1447303+flamber@users.noreply.github.com> * [[null]] is a valid response Previously, this said that a result of `[[null]]` was an empty result set, but in reality, it's a valid result set of a single column with a null value. Resolves #13571 Co-authored-by: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com> Co-authored-by: flamber <1447303+flamber@users.noreply.github.com> --- frontend/src/metabase/lib/dataset.js | 3 +-- .../scenarios/question/nulls.cy.spec.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/src/metabase/lib/dataset.js b/frontend/src/metabase/lib/dataset.js index d443daeb937..9859909ad84 100644 --- a/frontend/src/metabase/lib/dataset.js +++ b/frontend/src/metabase/lib/dataset.js @@ -20,9 +20,8 @@ type ColumnSetting = { enabled: boolean, }; -// Many aggregations result in [[null]] if there are no rows to aggregate after filters export const datasetContainsNoResults = (data: DatasetData): boolean => - data.rows.length === 0 || _.isEqual(data.rows, [[null]]); + data.rows == null || data.rows.length === 0; /** * @returns min and max for a value in a column diff --git a/frontend/test/metabase/scenarios/question/nulls.cy.spec.js b/frontend/test/metabase/scenarios/question/nulls.cy.spec.js index 848a44bd669..66fb337a856 100644 --- a/frontend/test/metabase/scenarios/question/nulls.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/nulls.cy.spec.js @@ -3,12 +3,39 @@ import { signInAsAdmin, openOrdersTable, popover, + withSampleDataset, } from "__support__/cypress"; describe("scenarios > question > null", () => { before(restore); beforeEach(signInAsAdmin); + it("should display rows whose value is `null` (metabase#13571)", () => { + withSampleDataset(({ ORDERS }) => { + cy.request("POST", "/api/card", { + name: "13571", + dataset_query: { + database: 1, + query: { + "source-table": 2, + fields: [ORDERS.DISCOUNT], + filter: ["=", ORDERS.ID, 1], + }, + type: "query", + }, + display: "table", + visualization_settings: {}, + }); + + // find and open previously created question + cy.visit("/collection/root"); + cy.findByText("13571").click(); + + cy.log("**'No Results since at least v0.34.3**"); + cy.findByText("No results!").should("not.exist"); + }); + }); + describe("aggregations with null values", () => { beforeEach(() => { cy.server(); -- GitLab