Browse Source

fix(nocodb): comparision_op -> comparison_op

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

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

@ -45,26 +45,26 @@ const removeLikeFilters = async (filter, actions: any[], ncMeta) => {
}; };
const migrateToBlankFilter = async (filter, actions: any[], ncMeta) => { const migrateToBlankFilter = async (filter, actions: any[], ncMeta) => {
if (['empty', 'null'].includes(filter.comparision_op)) { if (['empty', 'null'].includes(filter.comparison_op)) {
// migrate to blank // migrate to blank
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'blank', comparison_op: 'blank',
}, },
ncMeta ncMeta
) )
); );
} else if (['notempty', 'notnull'].includes(filter.comparision_op)) { } else if (['notempty', 'notnull'].includes(filter.comparison_op)) {
// migrate to not blank // migrate to not blank
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'notblank', comparison_op: 'notblank',
}, },
ncMeta ncMeta
) )
@ -80,7 +80,7 @@ const migrateMultiSelectEq = async (
ncMeta ncMeta
) => { ) => {
// only allow eq / neq // only allow eq / neq
if (!['eq', 'neq'].includes(filter.comparision_op)) return actions; if (!['eq', 'neq'].includes(filter.comparison_op)) return actions;
// if there is no value -> delete this filter // if there is no value -> delete this filter
if (!filter.value) { if (!filter.value) {
actions.push(await Filter.delete(filter.id, ncMeta)); actions.push(await Filter.delete(filter.id, ncMeta));
@ -103,27 +103,27 @@ const migrateMultiSelectEq = async (
actions.push(await Filter.delete(filter.id, ncMeta)); actions.push(await Filter.delete(filter.id, ncMeta));
return actions; return actions;
} }
if (filter.comparision_op === 'eq') { if (filter.comparison_op === 'eq') {
// migrate to `contains all of` // migrate to `contains all of`
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'anyof', comparison_op: 'anyof',
value: newFilterValue, value: newFilterValue,
}, },
ncMeta ncMeta
) )
); );
} else if (filter.comparision_op === 'neq') { } else if (filter.comparison_op === 'neq') {
// migrate to `doesn't contain all of` // migrate to `doesn't contain all of`
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'nanyof', comparison_op: 'nanyof',
value: newFilterValue, value: newFilterValue,
}, },
ncMeta ncMeta
@ -134,31 +134,31 @@ const migrateMultiSelectEq = async (
}; };
const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => {
if (['empty', 'null'].includes(filter.comparision_op)) { if (['empty', 'null'].includes(filter.comparison_op)) {
// migrate to checked // migrate to checked
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'checked', comparison_op: 'checked',
}, },
ncMeta ncMeta
) )
); );
} else if (['notempty', 'notnull'].includes(filter.comparision_op)) { } else if (['notempty', 'notnull'].includes(filter.comparison_op)) {
// migrate to not checked // migrate to not checked
actions.push( actions.push(
await Filter.update( await Filter.update(
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'notchecked', comparison_op: 'notchecked',
}, },
ncMeta ncMeta
) )
); );
} else if (filter.comparision_op === 'eq') { } else if (filter.comparison_op === 'eq') {
if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) {
// migrate to checked // migrate to checked
actions.push( actions.push(
@ -166,7 +166,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => {
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'checked', comparison_op: 'checked',
value: '', value: '',
}, },
ncMeta ncMeta
@ -176,7 +176,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => {
// 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.comparision_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 not checked // migrate to not checked
actions.push( actions.push(
@ -184,7 +184,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => {
filter.id, filter.id,
{ {
...filter, ...filter,
comparision_op: 'notchecked', comparison_op: 'notchecked',
value: '', value: '',
}, },
ncMeta ncMeta
@ -264,7 +264,7 @@ async function updateProjectMeta(ncMeta: NcMetaIO) {
let actions = []; let actions = [];
for (const filter of filters) { for (const filter of filters) {
if ( if (
['empty', 'notempty', 'null', 'notnull'].includes(filter.comparision_op) ['notempty', 'notnull', 'empty', 'null'].includes(filter.comparison_op)
) { ) {
projectHasEmptyOrFilters[filter.project_id] = true; projectHasEmptyOrFilters[filter.project_id] = true;
} }

Loading…
Cancel
Save