mirror of https://github.com/nocodb/nocodb
Wing-Kam Wong
2 years ago
1 changed files with 27 additions and 2 deletions
@ -1,13 +1,38 @@ |
|||||||
import { NcUpgraderCtx } from './NcUpgrader'; |
import { NcUpgraderCtx } from './NcUpgrader'; |
||||||
import { MetaTable } from '../utils/globals'; |
import { MetaTable } from '../utils/globals'; |
||||||
|
import Column from '../models/Column'; |
||||||
|
import Filter from '../models/Filter'; |
||||||
|
import { UITypes } from 'nocodb-sdk'; |
||||||
|
|
||||||
// as of 0.104.3, almost all filter operators are available to all column types
|
// as of 0.104.3, almost all filter operators are available to all column types
|
||||||
// while some of them aren't supposed to be shown
|
// while some of them aren't supposed to be shown
|
||||||
// this upgrader is to remove those unsupported filters / migrate to the correct filter
|
// this upgrader is to remove those unsupported filters / migrate to the correct filter
|
||||||
|
// changes:
|
||||||
|
// - remove `>`, `<`, `>=`, `<=` for text-based columns
|
||||||
|
|
||||||
export default async function ({ ncMeta }: NcUpgraderCtx) { |
export default async function ({ ncMeta }: NcUpgraderCtx) { |
||||||
const filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP); |
const filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP); |
||||||
|
const actions = []; |
||||||
for (const filter of filters) { |
for (const filter of filters) { |
||||||
console.log(filter); |
const col = await Column.get({ colId: filter.fk_column_id }, ncMeta); |
||||||
// TODO:
|
if (!col || !col.uidt) { |
||||||
|
// column not found -> skip
|
||||||
|
continue; |
||||||
|
} |
||||||
|
if ( |
||||||
|
[ |
||||||
|
UITypes.SingleLineText, |
||||||
|
UITypes.LongText, |
||||||
|
UITypes.PhoneNumber, |
||||||
|
UITypes.Email, |
||||||
|
UITypes.URL, |
||||||
|
].includes(col.uidt) |
||||||
|
) { |
||||||
|
// remove `>`, `<`, `>=`, `<=` for text-based columns
|
||||||
|
if (['gt', 'lt', 'gte', 'lte'].includes(filter.comparison_op)) { |
||||||
|
actions.push(await Filter.delete(filter, ncMeta)); |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
|
await Promise.all(actions); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue