You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by kg...@apache.org on 2021/06/23 10:10:44 UTC

[superset] branch master updated: fix(native-filters): Assume that temporal columns exist if column_types is undefined (#15324)

This is an automated email from the ASF dual-hosted git repository.

kgabryje pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new b89ee0c  fix(native-filters): Assume that temporal columns exist if column_types is undefined (#15324)
b89ee0c is described below

commit b89ee0cb388b06044903a114ee04f79160098840
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Wed Jun 23 12:09:58 2021 +0200

    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
---
 .../FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx   | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
index 65a4ec4..fb80888 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
@@ -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.