Browse Source

refactor(nocodb): replace duplicate arrays

pull/4969/head
Wing-Kam Wong 2 years ago
parent
commit
c464f4778a
  1. 10
      packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts

10
packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts

@ -143,6 +143,8 @@ const migrateMultiSelectEq = async (filter, col: Column, ncMeta) => {
const migrateToCheckboxFilter = (filter, ncMeta) => { const migrateToCheckboxFilter = (filter, ncMeta) => {
let actions = []; let actions = [];
const possibleTrueValues = ['true', 'True', '1', 'T', 'Y'];
const possibleFalseValues = ['false', 'False', '0', 'F', 'N'];
if (['empty', 'null'].includes(filter.comparison_op)) { if (['empty', 'null'].includes(filter.comparison_op)) {
// migrate to not checked // migrate to not checked
actions.push( actions.push(
@ -166,7 +168,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => {
) )
); );
} else if (filter.comparison_op === 'eq') { } else if (filter.comparison_op === 'eq') {
if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { if (possibleTrueValues.includes(filter.value)) {
// migrate to checked // migrate to checked
actions.push( actions.push(
Filter.update( Filter.update(
@ -178,7 +180,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => {
ncMeta ncMeta
) )
); );
} else if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { } else if (possibleFalseValues.includes(filter.value)) {
// migrate to notchecked // migrate to notchecked
actions.push( actions.push(
Filter.update( Filter.update(
@ -195,7 +197,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => {
actions.push(Filter.delete(filter.id, ncMeta)); actions.push(Filter.delete(filter.id, ncMeta));
} }
} else if (filter.comparison_op === 'neq') { } else if (filter.comparison_op === 'neq') {
if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { if (possibleFalseValues.includes(filter.value)) {
// migrate to checked // migrate to checked
actions.push( actions.push(
Filter.update( Filter.update(
@ -207,7 +209,7 @@ const migrateToCheckboxFilter = (filter, ncMeta) => {
ncMeta ncMeta
) )
); );
} else if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { } else if (possibleTrueValues.includes(filter.value)) {
// migrate to not checked // migrate to not checked
actions.push( actions.push(
Filter.update( Filter.update(

Loading…
Cancel
Save