The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Use MBQL lib for matching field refs in ValueSourceModal in parameters (#68431)
Alexander Polyankin6a01533ca7d8
diff --git a/frontend/src/metabase-lib/v1/Question.ts b/frontend/src/metabase-lib/v1/Question.tsindex 0968050b2de..0b3d1c7b990 100644--- a/frontend/src/metabase-lib/v1/Question.ts+++ b/frontend/src/metabase-lib/v1/Question.ts@@ -15,7 +15,6 @@ import {import type { NotificationTriggerType } from "metabase-lib/v1/Alert/constants";import type Database from "metabase-lib/v1/metadata/Database";import Metadata from "metabase-lib/v1/metadata/Metadata";-import type Table from "metabase-lib/v1/metadata/Table";import { getQuestionVirtualTableId } from "metabase-lib/v1/metadata/utils/saved-questions";import { getCardUiParameters } from "metabase-lib/v1/parameters/utils/cards";import { getTemplateTagParametersFromCard } from "metabase-lib/v1/parameters/utils/template-tags";@@ -581,23 +580,6 @@ class Question {return Lib.databaseID(query);}- legacyQueryTable(): Table | null {- const query = this.query();- const { isNative } = Lib.queryDisplayInfo(query);- if (isNative) {- return this.legacyNativeQuery().table();- } else {- const tableId = Lib.sourceTableOrCardId(query);- const metadata = this.metadata();- return metadata.table(tableId);- }- }-- legacyQueryTableId(): TableId | null {- const table = this.legacyQueryTable();- return table ? table.id : null;- }-isArchived(): boolean {return this._card && this._card.archived;}diff --git a/frontend/src/metabase-lib/v1/metadata/Field.ts b/frontend/src/metabase-lib/v1/metadata/Field.tsindex 5f251c1db7f..9e4157c8d28 100644--- a/frontend/src/metabase-lib/v1/metadata/Field.ts+++ b/frontend/src/metabase-lib/v1/metadata/Field.ts@@ -1,15 +1,12 @@// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-nocheck-import dayjs from "dayjs";import _ from "underscore";-import { coercions_for_type, is_coerceable } from "cljs/metabase.types.core";import { formatField, stripId } from "metabase/lib/formatting";import {getFieldValues,getRemappings,} from "metabase-lib/v1/queries/utils/field";-import { TYPE } from "metabase-lib/v1/types/constants";import {isAddress,isBoolean,@@ -27,8 +24,6 @@ import {isStringLike,isSummable,isTime,- isTypeFK,- isa,} from "metabase-lib/v1/types/utils/isa";import type {FieldFingerprint,@@ -229,20 +224,6 @@ export default class Field extends Base {return isFK(this);}- /**- * Predicate to decide whether `this` is comparable with `field`.- *- * Currently only the MongoBSONID erroneous case is ruled out to fix the issue #49149. To the best of my knowledge- * there's no logic on FE to reliably decide whether two columns are comparable. Trying to come up with that in ad-hoc- * manner could disable some cases that users may depend on.- */- isComparableWith(field) {- return this.effective_type === "type/MongoBSONID" ||- field.effective_type === "type/MongoBSONID"- ? this.effective_type === field.effective_type- : true;- }-/*** @returns {FieldValues}*/@@ -262,48 +243,6 @@ export default class Field extends Base {return getIconForField(this);}- reference() {- if (Array.isArray(this.id)) {- // if ID is an array, it's a MBQL field reference, typically "field"- return this.id;- } else if (this.field_ref) {- return this.field_ref;- } else {- return ["field", this.id, null];- }- }-- // BREAKOUTS-- /**- * Returns a default date/time unit for this field- */- getDefaultDateTimeUnit() {- try {- const fingerprint = this.fingerprint.type["type/DateTime"];- const days = dayjs(fingerprint.latest).diff(- dayjs(fingerprint.earliest),- "day",- );-- if (Number.isNaN(days) || this.isTime()) {- return "hour";- }-- if (days < 1) {- return "minute";- } else if (days < 31) {- return "day";- } else if (days < 365) {- return "week";- } else {- return "month";- }- } catch (e) {- return "day";- }- }-// REMAPPINGSstatic remappedField(fields: Field[]): Field | null {@@ -414,29 +353,6 @@ export default class Field extends Base {return typeof this.id !== "number";}- isJsonUnfolded() {- const database = this.table?.database;- return this.json_unfolding ?? database?.details?.["json-unfolding"] ?? true;- }-- canUnfoldJson() {- const database = this.table?.database;-- return (- isa(this.base_type, TYPE.JSON) &&- database != null &&- database.hasFeature("nested-field-columns")- );- }-- canCoerceType() {- return !isTypeFK(this.semantic_type) && is_coerceable(this.base_type);- }-- coercionStrategyOptions(): string[] {- return coercions_for_type(this.base_type);- }-/*** @private* @param {number} iddiff --git a/frontend/src/metabase-lib/v1/metadata/Field.unit.spec.ts b/frontend/src/metabase-lib/v1/metadata/Field.unit.spec.tsindex dbd51ffc920..7605867cba3 100644--- a/frontend/src/metabase-lib/v1/metadata/Field.unit.spec.ts+++ b/frontend/src/metabase-lib/v1/metadata/Field.unit.spec.ts@@ -3,7 +3,6 @@ import { checkNotNull } from "metabase/lib/types";import { TYPE } from "metabase-lib/v1/types/constants";import type { Database, Field, Table } from "metabase-types/api";import {- createMockDateTimeFieldFingerprint,createMockField,createMockFieldDimension,createMockTable,@@ -285,44 +284,6 @@ describe("Field", () => {});});- describe("getDefaultDateTimeUnit", () => {- describe("when the field is of type `type/DateTime`", () => {- it("should return 'day'", () => {- const field = setup({- fields: [- createMockField({- id: FIELD_ID,- }),- ],- });-- expect(field.getDefaultDateTimeUnit()).toBe("day");- });- });- });-- describe("when field is of type `type/DateTime`", () => {- it("should return a time unit depending on the number of days in the 'fingerprint'", () => {- const field = setup({- fields: [- createMockField({- id: FIELD_ID,- fingerprint: {- type: {- "type/DateTime": createMockDateTimeFieldFingerprint({- earliest: "2019-03-01T00:00:00Z",- latest: "2021-01-01T00:00:00Z",- }),- },- },- }),- ],- });-- expect(field.getDefaultDateTimeUnit()).toBe("month");- });- });-describe("remappedField", () => {it("should return the 'human readable' field tied to the field's dimension", () => {const field = setup({@@ -607,35 +568,4 @@ describe("Field", () => {});});});-- describe("isComparableWith", () => {- const field = setup({- fields: [- createMockField({- id: FIELD_ID,- effective_type: "type/MongoBSONID",- }),- createMockField({- id: 2,- effective_type: "type/Integer",- }),- ],- });- const metadata = field.metadata;- const mongoField = metadata?.field(FIELD_ID);- const integerField = metadata?.field(2);-- it("should return true for 2 MongoBSONID fields", () => {- expect(mongoField?.isComparableWith(mongoField)).toBe(true);- });-- it("should return true for 2 non-MongoBSONID fields", () => {- expect(integerField?.isComparableWith(integerField)).toBe(true);- });-- it("should return false for MongoBSONID field and other field", () => {- expect(mongoField?.isComparableWith(integerField)).toBe(false);- expect(integerField?.isComparableWith(mongoField)).toBe(false);- });- });});diff --git a/frontend/src/metabase-lib/v1/parameters/utils/parameter-source.unit.spec.ts b/frontend/src/metabase-lib/v1/parameters/utils/parameter-source.unit.spec.tsindex 6dcba8b2c87..8c69bedec2b 100644--- a/frontend/src/metabase-lib/v1/parameters/utils/parameter-source.unit.spec.ts+++ b/frontend/src/metabase-lib/v1/parameters/utils/parameter-source.unit.spec.ts@@ -128,7 +128,7 @@ describe("canListParameterValues", () => {values_source_type: "card",values_source_config: {card_id: 1,- value_field: ["field", noValuesField.id, null],+ value_field: ["field", NO_VALUES_FIELD_ID, null],},});diff --git a/frontend/src/metabase-lib/v1/queries/utils/native-query-table.ts b/frontend/src/metabase-lib/v1/queries/utils/native-query-table.tsindex 4cc7366c2a2..6d2a43b5081 100644--- a/frontend/src/metabase-lib/v1/queries/utils/native-query-table.ts+++ b/frontend/src/metabase-lib/v1/queries/utils/native-query-table.ts@@ -1,18 +1,11 @@import _ from "underscore";import type Table from "metabase-lib/v1/metadata/Table";-import { getQuestionVirtualTableId } from "metabase-lib/v1/metadata/utils/saved-questions";import type NativeQuery from "../NativeQuery";export function getNativeQueryTable(nativeQuery: NativeQuery): Table | null {const question = nativeQuery.question();- const isModel = question.type() === "model" && question.isSaved();-- if (isModel) {- return question.metadata().table(getQuestionVirtualTableId(question.id()));- }-const database = question.database();const collection = nativeQuery.collection();if (database && collection) {diff --git a/frontend/src/metabase-lib/v1/urls.ts b/frontend/src/metabase-lib/v1/urls.tsindex f594870af47..3e8ee952a22 100644--- a/frontend/src/metabase-lib/v1/urls.ts+++ b/frontend/src/metabase-lib/v1/urls.ts@@ -124,7 +124,7 @@ export function getComparisonDashboardUrl(questionWithFilters: Question,) {const questionId = question.id();- const tableId = question.legacyQueryTableId();+ const tableId = Lib.sourceTableOrCardId(question.query());const filterQuery = Lib.toLegacyQuery(questionWithFilters.query());const filter = filterQuery.type === "query" ? filterQuery.query.filter : null;const cellQuery = filterdiff --git a/frontend/src/metabase-types/api/parameters.ts b/frontend/src/metabase-types/api/parameters.tsindex e87efdffb60..f6ba79d24d9 100644--- a/frontend/src/metabase-types/api/parameters.ts+++ b/frontend/src/metabase-types/api/parameters.ts@@ -72,7 +72,7 @@ export type ValuesSourceType = null | "card" | "static-list";export interface ValuesSourceConfig {values?: string[] | ParameterValue[];card_id?: CardId;- value_field?: unknown[];+ value_field?: FieldReference;}export type VariableTarget = ["template-tag", string];diff --git a/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceModal.unit.spec.tsx b/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceModal.unit.spec.tsxindex 18895e8617c..378d71c978d 100644--- a/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceModal.unit.spec.tsx+++ b/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceModal.unit.spec.tsx@@ -17,6 +17,7 @@ import {setupUnauthorizedCollectionsEndpoints,} from "__support__/server-mocks";import { mockSettings } from "__support__/settings";+import { createMockEntitiesState } from "__support__/store";import {renderWithProviders,screen,@@ -48,11 +49,13 @@ describe("ValuesSourceModal", () => {createMockField({id: 1,base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),createMockField({id: 2,base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -213,14 +216,18 @@ describe("ValuesSourceModal", () => {result_metadata: [createMockField({id: 1,+ name: "id",display_name: "ID",base_type: "type/BigInteger",+ effective_type: "type/BigInteger",semantic_type: "type/PK",}),createMockField({id: 2,+ name: "category",display_name: "Category",base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -241,7 +248,7 @@ describe("ValuesSourceModal", () => {await userEvent.click(screen.getByRole("button", { name: "Done" }));expect(onSubmit).toHaveBeenCalledWith("card", {card_id: 1,- value_field: ["field", 2, null],+ value_field: ["field", "category", { "base-type": "type/Text" }],});});@@ -266,6 +273,7 @@ describe("ValuesSourceModal", () => {id: 2,display_name: "Category",base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -333,6 +341,7 @@ describe("ValuesSourceModal", () => {id: 2,display_name: "Category",base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -367,6 +376,7 @@ describe("ValuesSourceModal", () => {id: 2,display_name: "Category",base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -481,10 +491,12 @@ describe("ValuesSourceModal", () => {createMockField({id: 1,base_type: "type/Integer",+ effective_type: "type/Integer",}),createMockField({id: 2,base_type: "type/Integer",+ effective_type: "type/Integer",}),],});@@ -815,6 +827,10 @@ const setup = async ({{storeInitialState: createMockState({currentUser,+ entities: createMockEntitiesState({+ databases: [createMockDatabase()],+ questions: cards,+ }),settings: mockSettings({"show-metabase-links": showMetabaseLinks,"token-features": createMockTokenFeatures({ whitelabel: true }),diff --git a/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceTypeModal.tsx b/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceTypeModal.tsxindex 6ebde257f68..12ee77ee07b 100644--- a/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceTypeModal.tsx+++ b/frontend/src/metabase/parameters/components/ValuesSourceModal/ValuesSourceTypeModal.tsx@@ -18,8 +18,8 @@ import { connect, useSelector } from "metabase/lib/redux";import { getLearnUrl } from "metabase/selectors/settings";import { getShowMetabaseLinks } from "metabase/selectors/whitelabel";import { Box, Flex, Icon } from "metabase/ui";+import * as Lib from "metabase-lib";import type Question from "metabase-lib/v1/Question";-import type Field from "metabase-lib/v1/metadata/Field";import { getQuestionVirtualTableId } from "metabase-lib/v1/metadata/utils/saved-questions";import type { UiParameter } from "metabase-lib/v1/parameters/types";import { hasFields } from "metabase-lib/v1/parameters/utils/parameter-fields";@@ -32,6 +32,7 @@ import {isNumberParameter,} from "metabase-lib/v1/parameters/utils/parameter-type";import type {+ FieldReference,Parameter,ParameterValue,ParameterValues,@@ -58,6 +59,7 @@ import {} from "./ValuesSourceTypeModalComponents";import { getStaticValues, getValuesText } from "./utils";+const STAGE_INDEX = 0;interface ModalOwnProps {parameter: UiParameter;sourceType: ValuesSourceType;@@ -267,13 +269,19 @@ const CardSourceModal = ({onChangeSourceType,onChangeSourceConfig,}: CardSourceModalProps) => {- const fields = useMemo(() => {- return question ? getSupportedFields(question, parameter) : [];- }, [question, parameter]);+ const query = useMemo(() => {+ return question != null ? getQuestionBasedQuery(question) : undefined;+ }, [question]);++ const columns = useMemo(() => {+ return query != null ? getSupportedColumns(query, parameter) : [];+ }, [query, parameter]);const selectedField = useMemo(() => {- return getFieldByReference(fields, sourceConfig.value_field);- }, [fields, sourceConfig]);+ return query != null && sourceConfig.value_field != null+ ? getColumnByReference(query, columns, sourceConfig.value_field)+ : undefined;+ }, [query, columns, sourceConfig.value_field]);const { values, isError } = useParameterValues({parameter,@@ -288,13 +296,16 @@ const CardSourceModal = ({);const handleFieldChange = useCallback(- (event: SelectChangeEvent<Field>) => {+ (event: SelectChangeEvent<Lib.ColumnMetadata>) => {+ if (query == null) {+ return;+ }onChangeSourceConfig({...sourceConfig,- value_field: event.target.value.reference(),+ value_field: Lib.legacyRef(query, STAGE_INDEX, event.target.value),});},- [sourceConfig, onChangeSourceConfig],+ [query, sourceConfig, onChangeSourceConfig],);return (@@ -320,17 +331,19 @@ const CardSourceModal = ({{question && (<ModalSection><ModalLabel>{t`Column to supply the values`}</ModalLabel>- {fields.length ? (+ {query != null && columns.length ? (<Selectvalue={selectedField}placeholder={t`Pick a column…`}onChange={handleFieldChange}>- {fields.map((field, index) => (+ {columns.map((column, index) => (<Optionkey={index}- name={field.displayName()}- value={field}+ name={+ Lib.displayInfo(query, STAGE_INDEX, column).displayName+ }+ value={column}/>))}</Select>@@ -470,23 +483,30 @@ const getSourceValues = (values: ParameterValue[] = []) => {return values.map(([value]) => String(value));};-const getFieldByReference = (fields: Field[], fieldReference?: unknown[]) => {- return fields.find((field) => _.isEqual(field.reference(), fieldReference));+const getQuestionBasedQuery = (question: Question) => {+ const adhocQuestion = question.composeQuestion();+ return adhocQuestion.query();};-const getFieldFilter = (parameter: Parameter) => {- const type = getParameterType(parameter);- if (type === "number") {- return (field: Field) => field.isNumeric();- }- return (field: Field) => field.isString();+const getColumnByReference = (+ query: Lib.Query,+ columns: Lib.ColumnMetadata[],+ columnRef: FieldReference,+) => {+ const [columnIndex] = Lib.findColumnIndexesFromLegacyRefs(query, 0, columns, [+ columnRef,+ ]);+ return columns[columnIndex];};-const getSupportedFields = (question: Question, parameter: Parameter) => {- const fieldFilter = getFieldFilter(parameter);- const fields =- question.composeQuestionAdhoc().legacyQueryTable()?.fields ?? [];- return fields.filter(fieldFilter);+const getSupportedColumns = (query: Lib.Query, parameter: Parameter) => {+ const type = getParameterType(parameter);+ return Lib.fieldableColumns(query, 0).filter((column) => {+ if (type === "number") {+ return Lib.isNumeric(column);+ }+ return Lib.isStringOrStringLike(column);+ });};/**diff --git a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/common.unit.spec.tsx b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/common.unit.spec.tsxindex 44d0bc7a890..283ece9350b 100644--- a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/common.unit.spec.tsx+++ b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/common.unit.spec.tsx@@ -18,11 +18,13 @@ describe("ValuesSourceModal", () => {createMockField({id: 1,base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),createMockField({id: 2,base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -173,14 +175,18 @@ describe("ValuesSourceModal", () => {result_metadata: [createMockField({id: 1,+ name: "id",display_name: "ID",base_type: "type/BigInteger",+ effective_type: "type/BigInteger",semantic_type: "type/PK",}),createMockField({id: 2,+ name: "category",display_name: "Category",base_type: "type/Text",+ effective_type: "type/Text",semantic_type: "type/Category",}),],@@ -199,7 +205,7 @@ describe("ValuesSourceModal", () => {await userEvent.click(screen.getByRole("button", { name: "Done" }));expect(onSubmit).toHaveBeenCalledWith("card", {card_id: 1,- value_field: ["field", 2, null],+ value_field: ["field", "category", { "base-type": "type/Text" }],});});diff --git a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsxindex e910e5f558a..4f080b4f6e5 100644--- a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx+++ b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx@@ -14,6 +14,7 @@ import {setupUnauthorizedCollectionsEndpoints,} from "__support__/server-mocks";import { mockSettings } from "__support__/settings";+import { createMockEntitiesState } from "__support__/store";import { renderWithProviders, waitForLoaderToBeRemoved } from "__support__/ui";import { ROOT_COLLECTION } from "metabase/entities/collections";import { createMockUiParameter } from "metabase-lib/v1/parameters/mock";@@ -100,6 +101,10 @@ export const setup = async ({const state = createMockState({currentUser,+ entities: createMockEntitiesState({+ databases: [createMockDatabase()],+ questions: cards,+ }),settings: mockSettings({"show-metabase-links": showMetabaseLinks,"token-features": createMockTokenFeatures(tokenFeatures),diff --git a/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js b/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.jsindex 306d4638633..64e204a4e69 100644--- a/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js+++ b/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js@@ -9,6 +9,7 @@ import { createMockEntitiesState } from "__support__/store";import { fireEvent, renderWithProviders, screen } from "__support__/ui";import MetabaseSettings from "metabase/lib/settings";import { getMetadata } from "metabase/selectors/metadata";+import * as Lib from "metabase-lib";import Question from "metabase-lib/v1/Question";import { COMMON_DATABASE_FEATURES } from "metabase-types/api/mocks";import {@@ -430,7 +431,10 @@ describe("ViewTitleHeader", () => {describe("ViewHeader | Ad-hoc GUI question", () => {it("does not open details sidebar on table name click", async () => {const { question, onOpenModal } = setupAdHoc();- const tableName = question.legacyQueryTable().displayName();+ const table = question+ .metadata()+ .table(Lib.sourceTableOrCardId(question.query()));+ const tableName = table.displayName();fireEvent.click(await screen.findByText(tableName));diff --git a/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/QuestionDataSource.unit.spec.js b/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/QuestionDataSource.unit.spec.jsindex 1c632528849..7f27c6e6de8 100644--- a/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/QuestionDataSource.unit.spec.js+++ b/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/QuestionDataSource.unit.spec.js@@ -390,35 +390,38 @@ describe("QuestionDataSource", () => {describe(questionType, () => {it("displays table name", async () => {const { question } = setup({ card });- const node = await screen.findByText(- new RegExp(question.legacyQueryTable().displayName()),- );+ const table = question+ .metadata()+ .table(Lib.sourceTableOrCardId(question.query()));+ const node = await screen.findByText(new RegExp(table.displayName()));expect(node).toBeInTheDocument();expect(node.closest("a")).not.toBeInTheDocument();});it("displays table link in subhead variant", async () => {const { question } = setup({ card, subHead: true });- const node = await screen.findByText(- new RegExp(question.legacyQueryTable().displayName()),- );+ const table = question+ .metadata()+ .table(Lib.sourceTableOrCardId(question.query()));+ const node = await screen.findByText(new RegExp(table.displayName()));expect(areQuestionUrlsEquivalent(node.closest("a").href,- ML_Urls.getUrl(question.legacyQueryTable().newQuestion()),+ ML_Urls.getUrl(table.newQuestion()),),).toBe(true);});it("displays table link in object detail view", async () => {const { question } = setup({ card, isObjectDetail: true });- const node = await screen.findByText(- new RegExp(question.legacyQueryTable().displayName()),- );+ const table = question+ .metadata()+ .table(Lib.sourceTableOrCardId(question.query()));+ const node = await screen.findByText(new RegExp(table.displayName()));expect(areQuestionUrlsEquivalent(node.closest("a").href,- ML_Urls.getUrl(question.legacyQueryTable().newQuestion()),+ ML_Urls.getUrl(table.newQuestion()),),).toBe(true);});@@ -436,13 +439,14 @@ describe("QuestionDataSource", () => {describe(questionType, () => {it("displays schema name", async () => {const { question } = setup({ card });- const node = await screen.findByText(- question.legacyQueryTable().schema_name,- );+ const table = question+ .metadata()+ .table(Lib.sourceTableOrCardId(question.query()));+ const node = await screen.findByText(table.schema_name);expect(node).toBeInTheDocument();expect(node.closest("a")).toHaveAttribute("href",- Urls.browseSchema(question.legacyQueryTable()),+ Urls.browseSchema(table),);});});diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/utils.unit.spec.ts b/frontend/src/metabase/visualizations/components/ObjectDetail/utils.unit.spec.tsindex 25d0721ec6b..49550324e19 100644--- a/frontend/src/metabase/visualizations/components/ObjectDetail/utils.unit.spec.ts+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/utils.unit.spec.ts@@ -119,7 +119,7 @@ describe("ObjectDetail utils", () => {describe("getObjectName", () => {const question = new Question(card, metadata);- const table = question.legacyQueryTable();+ const table = metadata.table(ORDERS_ID);it("should get an entity name when there is an entity name column", () => {const name = getObjectName({