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

Fix filtering by join dimensions (#26156)

parent 4c39b164
No related branches found
No related tags found
No related merge requests found
......@@ -410,6 +410,10 @@ export default class Dimension {
return this._query;
}
setQuery(query: StructuredQuery): Dimension {
return this;
}
sourceDimension() {
return this._query && this._query.dimensionForSourceQuery(this);
}
......@@ -731,6 +735,20 @@ export class FieldDimension extends Dimension {
Object.freeze(this);
}
setQuery(query: StructuredQuery): FieldDimension {
return new FieldDimension(
this._fieldIdOrName,
this._options,
this._metadata,
query,
{
_fieldInstance: this._fieldInstance,
_subDisplayName: this._subDisplayName,
_subTriggerDisplayName: this._subTriggerDisplayName,
},
);
}
isEqual(somethingElse) {
if (isFieldDimension(somethingElse)) {
return (
......@@ -1154,6 +1172,15 @@ export class ExpressionDimension extends Dimension {
Object.freeze(this);
}
setQuery(query: StructuredQuery): ExpressionDimension {
return new ExpressionDimension(
this._expressionName,
this._options,
this._metadata,
query,
);
}
isEqual(somethingElse) {
if (isExpressionDimension(somethingElse)) {
return (
......@@ -1414,6 +1441,15 @@ export class AggregationDimension extends Dimension {
Object.freeze(this);
}
setQuery(query: StructuredQuery): AggregationDimension {
return new AggregationDimension(
this._aggregationIndex,
this._options,
this._metadata,
query,
);
}
aggregationIndex(): number {
return this._aggregationIndex;
}
......
......@@ -625,7 +625,7 @@ export default class Join extends MBQLObjectClause {
joinedDimension(dimension: Dimension) {
if (dimension instanceof FieldDimension) {
return dimension.withJoinAlias(this.alias);
return dimension.withJoinAlias(this.alias).setQuery(this.query());
}
console.warn("Don't know how to create joined dimension with:", dimension);
......
import { restore, visitQuestionAdhoc } from "__support__/e2e/helpers";
import { SAMPLE_DB_ID } from "__support__/e2e/cypress_data";
import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database";
const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;
const questionDetails = {
dataset_query: {
type: "query",
database: SAMPLE_DB_ID,
query: {
"source-query": {
"source-table": ORDERS_ID,
joins: [
{
fields: "all",
"source-table": PEOPLE_ID,
condition: [
"=",
["field", ORDERS.USER_ID, null],
["field", PEOPLE.ID, { "join-alias": "People - User" }],
],
alias: "People - User",
},
],
aggregation: [["count"]],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
},
filter: [">", ["field", "count", { "base-type": "type/Integer" }], 0],
},
},
};
describe("issue 25990", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.intercept("POST", `/api/dataset`).as("dataset");
});
it("should allow to filter by a column in a joined table (metabase#25990)", () => {
visitQuestionAdhoc(questionDetails);
cy.findByText("Filter").click();
cy.findByText("People - User").click();
cy.findByPlaceholderText("Enter an ID").type("10");
cy.button("Apply Filters").click();
cy.wait("@dataset");
cy.findByText("ID is 10").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