Skip to content

Commit 42341b6

Browse files
authored
fix(server-rest): filters at different hierarchies are not properly combined (#2054)
1 parent 718fd67 commit 42341b6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/server/src/api/rest/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,6 @@ class RequestHandler extends APIHandlerBase {
15281528
}
15291529

15301530
const items: any[] = [];
1531-
let currType = typeInfo;
15321531

15331532
for (const [key, value] of Object.entries(query)) {
15341533
if (!value) {
@@ -1554,6 +1553,7 @@ class RequestHandler extends APIHandlerBase {
15541553

15551554
const item: any = {};
15561555
let curr = item;
1556+
let currType = typeInfo;
15571557

15581558
for (const filterValue of enumerate(value)) {
15591559
for (let i = 0; i < filterKeys.length; i++) {

packages/server/tests/api/rest.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,26 @@ describe('REST server tests', () => {
633633
prisma,
634634
});
635635
expect(r.body.data).toHaveLength(0);
636+
r = await handler({
637+
method: 'get',
638+
path: '/post',
639+
query: {
640+
['filter[author][email]']: '[email protected]',
641+
['filter[title]']: 'Post1',
642+
},
643+
prisma,
644+
});
645+
expect(r.body.data).toHaveLength(1);
646+
r = await handler({
647+
method: 'get',
648+
path: '/post',
649+
query: {
650+
['filter[author][email]']: '[email protected]',
651+
['filter[title]']: 'Post2',
652+
},
653+
prisma,
654+
});
655+
expect(r.body.data).toHaveLength(0);
636656

637657
// to-one relation filter
638658
r = await handler({

0 commit comments

Comments
 (0)