From e74d065d963d04a9b5a634ec86dbe339f9318738 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 27 Sep 2022 14:21:48 +0530 Subject: [PATCH] fix(api): handle if coloptions is null/undefined Signed-off-by: Pranav C --- .../lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index cc97f1b124..303ea7ec65 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -2357,10 +2357,12 @@ class BaseModelSqlv2 { if (args.options?.length) { groupingValues = new Set(args.options); } else if (column.uidt === UITypes.SingleSelect) { - const colOptions = await column.getColOptions< - SelectOption[] & { options } - >(); - groupingValues = new Set(colOptions.options.map((opt) => opt.title)); + const colOptions = await column.getColOptions<{ + options: SelectOption[]; + }>(); + groupingValues = new Set( + (colOptions?.options ?? []).map((opt) => opt.title) + ); groupingValues.add(null); } else { groupingValues = new Set(