mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:56:13 +00:00
fix: not in operator with null value record (#377)
This commit is contained in:
parent
c4b5f4f84b
commit
0467093dfd
33
packages/core/database/src/__tests__/operator/notIn.test.ts
Normal file
33
packages/core/database/src/__tests__/operator/notIn.test.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { mockDatabase } from '../index';
|
||||||
|
import Database from '../../database';
|
||||||
|
|
||||||
|
describe('ne operator', () => {
|
||||||
|
let db: Database;
|
||||||
|
let Test;
|
||||||
|
beforeEach(async () => {
|
||||||
|
db = mockDatabase({});
|
||||||
|
|
||||||
|
Test = db.collection({
|
||||||
|
name: 'tests',
|
||||||
|
fields: [{ type: 'string', name: 'name' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
await db.sync();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await db.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should notIn with null', async () => {
|
||||||
|
await db.getRepository('tests').create({});
|
||||||
|
|
||||||
|
const results = await db.getRepository('tests').count({
|
||||||
|
filter: {
|
||||||
|
'name.$notIn': ['123'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(results).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
@ -5,4 +5,5 @@ export default {
|
|||||||
...require('./empty').default,
|
...require('./empty').default,
|
||||||
...require('./string').default,
|
...require('./string').default,
|
||||||
...require('./ne').default,
|
...require('./ne').default,
|
||||||
|
...require('./notIn').default,
|
||||||
};
|
};
|
||||||
|
12
packages/core/database/src/operators/notIn.ts
Normal file
12
packages/core/database/src/operators/notIn.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { Op } from 'sequelize';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
$notIn(val, ctx) {
|
||||||
|
return {
|
||||||
|
[Op.or]: {
|
||||||
|
[Op.notIn]: val,
|
||||||
|
[Op.is]: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user