Skip to content

Commit

Permalink
Migrate _serializeForUrl method to MLv2 (metabase#37632)
Browse files Browse the repository at this point in the history
* Migrate `_serializeForUrl` method to MLv2

* Use MLv2 function to compare queries

---------

Co-authored-by: Alexander Polyankin <[email protected]>
  • Loading branch information
nemanjaglumac and ranquild authored Jan 18, 2024
1 parent 035d478 commit 03d6dba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions frontend/src/metabase-lib/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,14 +995,13 @@ class Question {
includeDisplayIsLocked = false,
creationType,
} = {}) {
const query = clean
? this.legacyQuery({ useStructuredQuery: true }).clean()
: this.legacyQuery({ useStructuredQuery: true });
const query = clean ? Lib.dropStageIfEmpty(this.query()) : this.query();

const cardCopy = {
name: this._card.name,
description: this._card.description,
collection_id: this._card.collection_id,
dataset_query: query.datasetQuery(),
dataset_query: Lib.toLegacyQuery(query),
display: this._card.display,
parameters: this._card.parameters,
dataset: this._card.dataset,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/metabase-lib/queries/utils/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from "underscore";
import { updateIn } from "icepick";

import { copy } from "metabase/lib/utils";
import * as Lib from "metabase-lib";
import { normalizeParameterValue } from "metabase-lib/parameters/utils/parameter-values";
import { deriveFieldOperatorFromParameter } from "metabase-lib/parameters/utils/operators";
import * as Q_DEPRECATED from "metabase-lib/queries/utils"; // legacy
Expand All @@ -20,7 +21,7 @@ function cardVisualizationIsEquivalent(cardA, cardB) {
export function cardQueryIsEquivalent(cardA, cardB) {
cardA = updateIn(cardA, ["dataset_query", "parameters"], p => p || []);
cardB = updateIn(cardB, ["dataset_query", "parameters"], p => p || []);
return _.isEqual(
return Lib.areLegacyQueriesEqual(
_.pick(cardA, "dataset_query"),
_.pick(cardB, "dataset_query"),
);
Expand Down

0 comments on commit 03d6dba

Please sign in to comment.