From c464f4778a84ee4ced92fb229009993c95fbbb44 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 17:36:50 +0800 Subject: [PATCH] refactor(nocodb): replace duplicate arrays --- .../lib/version-upgrader/ncFilterUpgrader_0104004.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts b/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts index 4937f5e49d..e0d3905a12 100644 --- a/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts +++ b/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts @@ -143,6 +143,8 @@ const migrateMultiSelectEq = async (filter, col: Column, ncMeta) => { const migrateToCheckboxFilter = (filter, ncMeta) => { let actions = []; + const possibleTrueValues = ['true', 'True', '1', 'T', 'Y']; + const possibleFalseValues = ['false', 'False', '0', 'F', 'N']; if (['empty', 'null'].includes(filter.comparison_op)) { // migrate to not checked actions.push( @@ -166,7 +168,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => { ) ); } else if (filter.comparison_op === 'eq') { - if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { + if (possibleTrueValues.includes(filter.value)) { // migrate to checked actions.push( Filter.update( @@ -178,7 +180,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => { ncMeta ) ); - } else if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { + } else if (possibleFalseValues.includes(filter.value)) { // migrate to notchecked actions.push( Filter.update( @@ -195,7 +197,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => { actions.push(Filter.delete(filter.id, ncMeta)); } } else if (filter.comparison_op === 'neq') { - if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { + if (possibleFalseValues.includes(filter.value)) { // migrate to checked actions.push( Filter.update( @@ -207,7 +209,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => { ncMeta ) ); - } else if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { + } else if (possibleTrueValues.includes(filter.value)) { // migrate to not checked actions.push( Filter.update(