Browse Source

fix(nocodb): checkbox upgrader logic

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
f0bdf74dcb
  1. 34
      packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104004.ts

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

@ -153,25 +153,25 @@ const migrateMultiSelectEq = async (
const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => {
if (['empty', 'null'].includes(filter.comparison_op)) { if (['empty', 'null'].includes(filter.comparison_op)) {
// migrate to checked // migrate to not checked
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparison_op: 'checked', comparison_op: 'notchecked',
}, },
ncMeta ncMeta
) )
); );
} else if (['notempty', 'notnull'].includes(filter.comparison_op)) { } else if (['notempty', 'notnull'].includes(filter.comparison_op)) {
// migrate to not checked // migrate to checked
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparison_op: 'notchecked', comparison_op: 'checked',
}, },
ncMeta ncMeta
) )
@ -190,12 +190,38 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => {
ncMeta ncMeta
) )
); );
} else if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) {
// migrate to notchecked
actions.push(
await Filter.update(
filter.id,
{
...filter,
comparison_op: 'notchecked',
value: '',
},
ncMeta
)
);
} else { } else {
// invalid value - good to delete // invalid value - good to delete
actions.push(await Filter.delete(filter.id, ncMeta)); actions.push(await 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 (['false', 'False', '0', 'F', 'N'].includes(filter.value)) {
// migrate to checked
actions.push(
await Filter.update(
filter.id,
{
...filter,
comparison_op: 'checked',
value: '',
},
ncMeta
)
);
} else if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) {
// migrate to not checked // migrate to not checked
actions.push( actions.push(
await Filter.update( await Filter.update(

Loading…
Cancel
Save