fix(native-filters): Assume that temporal columns exist if column_types is undefined (#15324)

* fix(native-filters): Assume that temporal columns exist if column_types is undefined

* Allow column_types to be an empty array
This commit is contained in:
Kamil Gabryjelski 2021-06-23 12:09:58 +02:00 committed by GitHub
parent 6324490dd3
commit b89ee0cb38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import {
SupersetApiError,
t,
GenericDataType,
ensureIsArray,
} from '@superset-ui/core';
import {
ColumnMeta,
@ -275,9 +276,15 @@ const FILTER_TYPE_NAME_MAPPING = {
};
// TODO: add column_types field to DatasourceMeta
// We return true if column_types is undefined or empty as a precaution against backend failing to return column_types
const hasTemporalColumns = (
dataset: DatasourceMeta & { column_types: GenericDataType[] },
) => dataset?.column_types?.includes(GenericDataType.TEMPORAL);
) => {
const columnTypes = ensureIsArray(dataset?.column_types);
return (
columnTypes.length === 0 || columnTypes.includes(GenericDataType.TEMPORAL)
);
};
/**
* The configuration form for a specific filter.