Skip to content
Snippets Groups Projects
Unverified Commit 707f1404 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[QC] Remove `hasAnyClauses` method from `StructuredQuery` prototype (#38525)

* [QC] Remove `hasAnyClauses` method from the `StructuredQuery` prototype

* [QC] Remove `hasExpressions` method from the `StructuredQuery` prototype

* [QC] Remove `hasFilters` method from the `StructuredQuery` prototype

* [QC] Remove private `hasSorts` method from the `StructuredQuery` prototype

* [QC] Remove `hasLimit` method from the `StructuredQuery` prototype

* [QC] Remove private `indexOfField` method from the `StructuredQuery` prototype
parent 2c71bf0d
No related branches found
No related tags found
No related merge requests found
......@@ -315,34 +315,6 @@ class StructuredQuery extends AtomicQuery {
return !!this.table();
}
hasAnyClauses() {
// this list should be kept in sync with BE in `metabase.models.card/model-supports-implicit-actions?`
const query = this.getMLv2Query();
const stageIndex = this.getQueryStageIndex();
const hasJoins = Lib.joins(query, stageIndex).length > 0;
return (
hasJoins ||
this.hasExpressions() ||
this.hasFilters() ||
this.hasAggregations() ||
this.hasBreakouts() ||
this._hasSorts() ||
this.hasLimit() ||
this._hasFields()
);
}
hasExpressions() {
return Object.keys(this.expressions()).length > 0;
}
hasFilters() {
return this.filters().length > 0;
}
hasAggregations() {
return this.aggregations().length > 0;
}
......@@ -351,16 +323,6 @@ class StructuredQuery extends AtomicQuery {
return this.breakouts().length > 0;
}
_hasSorts() {
const query = this.getMLv2Query();
return Lib.orderBys(query).length > 0;
}
hasLimit(stageIndex = this.queries().length - 1) {
const query = this.getMLv2Query();
return Lib.hasLimit(query, stageIndex);
}
_hasFields() {
return this.fields().length > 0;
}
......@@ -815,10 +777,6 @@ class StructuredQuery extends AtomicQuery {
return query;
}
_indexOfField(fieldRef) {
return this.fields().findIndex(f => _.isEqual(f, fieldRef));
}
// FIELDS
fields() {
// FIMXE: implement field functions in query lib
......
......@@ -16,18 +16,6 @@ const ordersTable = metadata.table(ORDERS_ID);
const FILTER = ["=", ["field", ORDERS.TOTAL, null], 42];
describe("StructuredQuery", () => {
describe("hasFilters", () => {
it("should return false for queries without filters", () => {
const q = ordersTable.legacyQuery({ useStructuredQuery: true });
expect(q.hasFilters()).toBe(false);
});
it("should return true for queries with filters", () => {
const q = ordersTable
.legacyQuery({ useStructuredQuery: true })
.filter(FILTER);
expect(q.hasFilters()).toBe(true);
});
});
describe("filters", () => {
it("should work as raw MBQL", () => {
const q = ordersTable
......
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