Browse Source

feat(nocodb): numeric-based columns filter migration

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
17dd51fd73
  1. 22
      packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104003.ts

22
packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0104003.ts

@ -9,6 +9,7 @@ import { UITypes } from 'nocodb-sdk';
// this upgrader is to remove those unsupported filters / migrate to the correct filter
// changes:
// - remove `>`, `<`, `>=`, `<=` for text-based columns
// - remove `like`, `null`, and `empty` for numeric-based columns - migrate to `blank` from `null` and `empty`
export default async function ({ ncMeta }: NcUpgraderCtx) {
const filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP);
@ -32,6 +33,27 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
if (['gt', 'lt', 'gte', 'lte'].includes(filter.comparison_op)) {
actions.push(await Filter.delete(filter, ncMeta));
}
} else if (
[
UITypes.Duration,
UITypes.Currency,
UITypes.Percent,
UITypes.Number,
UITypes.Decimal,
UITypes.Rating,
UITypes.Rollup,
].includes(col.uidt)
) {
if (['like', 'nlike'].includes(filter.comparison_op)) {
// remove `is like`, `is not like`
actions.push(await Filter.delete(filter, ncMeta));
} else if (
['null', 'notnull', 'empty', 'notempty'].includes(filter.comparison_op)
) {
// remove `is null`, `is not null`, `is empty`, `is not empty`
actions.push(await Filter.delete(filter, ncMeta));
// TODO: migrate to blank / not blank
}
}
}
await Promise.all(actions);

Loading…
Cancel
Save