Skip to content
Snippets Groups Projects
Unverified Commit 1fca7051 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix segments in case custom expressions (#24939)

parent 9e39ffa4
No related branches found
No related tags found
No related merge requests found
......@@ -319,7 +319,7 @@ export const adjustBooleans = tree =>
const [op, _id, opts] = operand;
const isBooleanField =
op === "field" && opts?.["base-type"] === "type/Boolean";
if (isBooleanField || op === "segment") {
if (isBooleanField) {
return withAST([["=", operand, true], value], operand);
}
return [operand, value];
......
import {
enterCustomColumnDetails,
openOrdersTable,
restore,
visualize,
} from "__support__/e2e/helpers";
import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database";
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
const segmentDetails = {
name: "OrdersSegment",
description: "All orders with a total under $100.",
table_id: ORDERS_ID,
definition: {
"source-table": ORDERS_ID,
aggregation: [["count"]],
filter: ["<", ["field", ORDERS.TOTAL, null], 100],
},
};
const customColumnDetails = {
name: "CustomColumn",
formula: 'case([OrdersSegment], "Segment", "Other")',
};
describe("issue 24922", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.request("POST", "/api/segment", segmentDetails);
});
it("should allow segments in case custom expressions (metabase#24922)", () => {
openOrdersTable({ mode: "notebook" });
cy.findByText("Custom column").click();
enterCustomColumnDetails(customColumnDetails);
cy.button("Done").click();
visualize();
cy.findByText("CustomColumn").should("be.visible");
});
});
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