Transformations: Fix field named Time matching all time fields

The byName and byNames matchers fall back to matching any time field when
the configured name is Time or time, so configs keep working after the
dataplane rename. The fallback also kicked in when the frame already had a
field with that name, so hiding `time` in Organize fields hid every time
field and Filter by name could not drop the other ones.

The fallback now only applies when no field in the frame has that name or
display name.
This commit is contained in:
dualfroz committed 2026-10-17 03:36:27 +02:00
1 parent 00681578cc
commit 47a8d79948
2 files changed
+40 -2

No files matched your search

@@ -456,6 +456,36 @@ it('Support fallback multiple names matchers', () => {
expect(matcher(frame.fields[1], frame, [])).toBeFalsy();
});
it('Should only match the field named time when the frame has more time fields', () => {
const frame: DataFrame = {
fields: [
{ name: 'time', type: FieldType.time, config: {}, values: [1, 2] },
{ name: 'Shifted Time', type: FieldType.time, config: {}, values: [3, 4] },
{ name: 'A-series', type: FieldType.number, config: {}, values: [1, 2] },
],
length: 2,
};
const nameMatcher = getFieldMatcher({
id: FieldMatcherID.byName,
options: 'time',
});
expect(nameMatcher(frame.fields[0], frame, [frame])).toBeTruthy();
expect(nameMatcher(frame.fields[1], frame, [frame])).toBeFalsy();
expect(nameMatcher(frame.fields[2], frame, [frame])).toBeFalsy();
const namesMatcher = getFieldMatcher({
id: FieldMatcherID.byNames,
options: {
mode: ByNamesMatcherMode.include,
names: ['time', 'A-series'],
},
});
expect(namesMatcher(frame.fields[0], frame, [frame])).toBeTruthy();
expect(namesMatcher(frame.fields[1], frame, [frame])).toBeFalsy();
expect(namesMatcher(frame.fields[2], frame, [frame])).toBeTruthy();
});
describe('Fields returned by query with refId', () => {
it('Match all fields in frame with refId: A', () => {
const data = [