mirror of
https://github.com/apache/superset.git
synced 2026-04-07 10:31:50 +00:00
fix(AlteredSliceTag): not display undefined filter value for chart change record (#38883)
Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
@@ -52,7 +52,7 @@ export const formatValueHandler = (
|
||||
v.comparator && v.comparator.constructor === Array
|
||||
? `[${v.comparator.join(', ')}]`
|
||||
: v.comparator;
|
||||
return `${v.subject} ${v.operator} ${filterVal}`;
|
||||
return filterVal ? `${v.subject} ${v.operator} ${filterVal}` : `${v.subject} ${v.operator}`;
|
||||
})
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
@@ -258,6 +258,33 @@ describe('formatValueHandler', () => {
|
||||
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
test('formats unary filter', () => {
|
||||
const filters = [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
operator: 'IS NULL',
|
||||
subject: 'a',
|
||||
},
|
||||
{
|
||||
clause: 'WHERE',
|
||||
comparator: ['hu', 'ho', 'ha'],
|
||||
expressionType: 'SIMPLE',
|
||||
operator: 'NOT IN',
|
||||
subject: 'b',
|
||||
},
|
||||
];
|
||||
const key = 'adhoc_filters';
|
||||
|
||||
const expected = 'a IS NULL, b NOT IN [hu, ho, ha]';
|
||||
const formattedValue: string | number = formatValueHandler(
|
||||
filters,
|
||||
key,
|
||||
controlsMap,
|
||||
);
|
||||
|
||||
expect(formattedValue).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
|
||||
Reference in New Issue
Block a user