metabase icon indicating copy to clipboard operation
metabase copied to clipboard

findColumnIndexesFromLegacyRefs doesn't not find legacy columns for nested queries with integer-based field refs

Open ranquild opened this issue 1 year ago • 0 comments

Describe the bug

Blocks https://github.com/metabase/metabase/pull/38820

const [fieldIndex] = Lib.findColumnIndexesFromLegacyRefs(
    query,
    stageIndex,
    fields.map(field => Lib.fromLegacyColumn(query, stageIndex, field)),
    [fieldRef],
  );

It doesn't find the column if the query is based on a saved question and numeric field ids are used. I believe it has something to do with "broken integer-based" field refs for nested queries, which seems to be handled for regular MLv2 columns (e.g. visibleColumns) but not when converting from a legacy column.

Screenshot 2024-02-18 at 15 21 07

To Reproduce

branch legacy-parameter-target e2e test e2e/test/scenarios/dashboard-filters/reproductions/12985-dropdown-search.cy.spec.js

relevant code:

const [fieldIndex] = Lib.findColumnIndexesFromLegacyRefs(
    query,
    stageIndex,
    fields.map(field => Lib.fromLegacyColumn(query, stageIndex, field)),
    [fieldRef],
  );

Expected behavior

findColumnIndexesFromLegacyRefs should find the column

Logs

No response

Information about your Metabase installation

-

Severity

P2

Additional context

No response

ranquild avatar Feb 18 '24 13:02 ranquild