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) => {
if (['empty', 'null'].includes(filter.comparison_op)) {
// migrate to checked
// migrate to not checked
actions.push(
await Filter.update(
filter.id,
{
...filter,
comparison_op: 'checked',
comparison_op: 'notchecked',
},
ncMeta
)
);
} else if (['notempty', 'notnull'].includes(filter.comparison_op)) {
// migrate to not checked
// migrate to checked
actions.push(
await Filter.update(
filter.id,
{
...filter,
comparison_op: 'notchecked',
comparison_op: 'checked',
},
ncMeta
)
@ -190,12 +190,38 @@ const migrateToCheckboxFilter = async (filter, actions: any[], 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 {
// invalid value - good to delete
actions.push(await Filter.delete(filter.id, ncMeta));
}
} else if (filter.comparison_op === 'neq') {
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
actions.push(
await Filter.update(

Loading…
Cancel
Save