Skip to content
Snippets Groups Projects
Unverified Commit db5ecb9c authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Fix join validation (#31869)

parent 00648467
No related branches found
No related tags found
No related merge requests found
import {
popover,
restore,
startNewQuestion,
selectSavedQuestionsToJoin,
visualize,
} from "e2e/support/helpers";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, PEOPLE, PEOPLE_ID } =
SAMPLE_DATABASE;
const Q1 = {
"source-table": ORDERS_ID,
joins: [
{
fields: "all",
alias: "Products",
"source-table": PRODUCTS_ID,
condition: [
"=",
["field", ORDERS.PRODUCT_ID, null],
["field", PRODUCTS.ID, { "join-alias": "Products" }],
],
},
{
fields: "all",
alias: "People — User",
"source-table": PEOPLE_ID,
condition: [
"=",
["field", ORDERS.USER_ID, null],
["field", PEOPLE.ID, { "join-alias": "People — User" }],
],
},
],
aggregation: [["count"]],
breakout: [
[
"field",
PRODUCTS.CATEGORY,
{ "base-type": "type/Text", "join-alias": "Products" },
],
],
};
const Q2 = {
"source-table": PRODUCTS_ID,
aggregation: [["count"]],
breakout: [["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }]],
};
describe("issue 31769", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.createQuestion({ name: "Q1", query: Q1 }).then(() => {
cy.createQuestion({ name: "Q2", query: Q2 }).then(response => {
cy.wrap(response.body.id).as("card_id_q2");
startNewQuestion();
});
});
});
it("shouldn't drop joins using MLv2 format (metabase#31769)", () => {
selectSavedQuestionsToJoin("Q1", "Q2");
popover().findByText("Products → Category").click();
popover().findByText("Category").click();
visualize();
// Asserting there're two columns from Q1 and two columns from Q2
cy.findAllByTestId("header-cell").should("have.length", 4);
cy.get("@card_id_q2").then(cardId => {
cy.findByTestId("TableInteractive-root")
.findByText(`Question ${cardId} → Category`)
.should("exist");
});
cy.findByTestId("TableInteractive-root")
.findByText("Products → Category")
.should("exist");
});
});
......@@ -661,7 +661,9 @@ export default class Join extends MBQLObjectClause {
const dimensions = [...this.parentDimensions(), ...this.joinDimensions()];
return dimensions.every(
dimension =>
dimensionOptions.hasDimension(dimension.getMLv1CompatibleDimension()) || // For some GUI queries created in earlier versions of Metabase,
dimensionOptions.hasDimension(dimension) ||
dimensionOptions.hasDimension(dimension.getMLv1CompatibleDimension()) ||
// For some GUI queries created in earlier versions of Metabase,
// some dimensions are described as field literals
// Usually it's [ "field", field_numeric_id, null|object ]
// And field literals look like [ "field", "PRODUCT_ID", {'base-type': 'type/Integer' } ]
......
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