Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): orderBy for composite types (#12004)
- Loading branch information
Showing
30 changed files
with
853 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
|
||
pnpm-lock.yaml | ||
*.tsbuildinfo | ||
junit.xml | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...s__/integration/happy/composites-mongo/__helpers__/build-data/commentOptionalPropDataA.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function commentOptionalPropDataA(id: string) { | ||
return { | ||
id: id, | ||
country: 'France', | ||
content: { | ||
set: { | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...s__/integration/happy/composites-mongo/__helpers__/build-data/commentOptionalPropDataB.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function commentOptionalPropDataB(id: string) { | ||
return { | ||
id: id, | ||
country: 'France', | ||
content: { | ||
text: 'Goodbye World', | ||
upvotes: [ | ||
{ | ||
vote: false, | ||
userId: '11', | ||
}, | ||
{ | ||
vote: true, | ||
userId: '12', | ||
}, | ||
], | ||
}, | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...s__/integration/happy/composites-mongo/__helpers__/build-data/commentRequiredListDataA.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function commentRequiredListDataA(id: string) { | ||
return { | ||
id: id, | ||
country: 'France', | ||
contents: { | ||
set: { | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...s__/integration/happy/composites-mongo/__helpers__/build-data/commentRequiredListDataB.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export function commentRequiredListDataB(id: string) { | ||
return { | ||
id: id, | ||
country: 'France', | ||
contents: { | ||
set: [ | ||
{ | ||
text: 'Goodbye World', | ||
upvotes: { | ||
vote: false, | ||
userId: '11', | ||
}, | ||
}, | ||
{ | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
], | ||
}, | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...s__/integration/happy/composites-mongo/__helpers__/build-data/commentRequiredPropDataA.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function commentRequiredPropDataA(id: string) { | ||
return { | ||
id: id, | ||
country: 'France', | ||
content: { | ||
set: { | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...s__/integration/happy/composites-mongo/__helpers__/build-data/commentRequiredPropDataB.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function commentRequiredPropDataB(id: string) { | ||
return { | ||
id: id, | ||
country: 'France', | ||
content: { | ||
text: 'Goodbye World', | ||
upvotes: [ | ||
{ | ||
vote: false, | ||
userId: '11', | ||
}, | ||
{ | ||
vote: true, | ||
userId: '12', | ||
}, | ||
], | ||
}, | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
packages/client/src/__tests__/integration/happy/composites-mongo/aggregate/list.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { getTestClient } from '../../../../../utils/getTestClient' | ||
|
||
const describeIf = (condition: boolean) => (condition ? describe : describe.skip) | ||
|
||
let PrismaClient, prisma | ||
|
||
const id = '6ccccccccccccccccccccccc' | ||
|
||
/** | ||
* Test aggregate operations on list composite fields | ||
*/ | ||
describeIf(!process.env.TEST_SKIP_MONGODB)('aggregate > list', () => { | ||
beforeAll(async () => { | ||
PrismaClient = await getTestClient('../') | ||
prisma = new PrismaClient() | ||
}) | ||
|
||
beforeEach(async () => { | ||
await prisma.commentRequiredList.deleteMany({ where: { id } }) | ||
await prisma.commentRequiredList.create({ | ||
data: { | ||
id, | ||
country: 'France', | ||
contents: { | ||
set: { | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
afterEach(async () => { | ||
await prisma.$disconnect() | ||
}) | ||
|
||
/** | ||
* Simple aggregate | ||
*/ | ||
test('simple', async () => { | ||
const comment = await prisma.commentRequiredList.aggregate({ | ||
where: { id }, | ||
orderBy: { | ||
contents: { | ||
_count: 'asc', | ||
}, | ||
}, | ||
_count: true, | ||
}) | ||
|
||
expect(comment).toMatchInlineSnapshot(` | ||
Object { | ||
_count: 1, | ||
} | ||
`) | ||
}) | ||
}) |
63 changes: 63 additions & 0 deletions
63
packages/client/src/__tests__/integration/happy/composites-mongo/aggregate/optional.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { getTestClient } from '../../../../../utils/getTestClient' | ||
|
||
const describeIf = (condition: boolean) => (condition ? describe : describe.skip) | ||
|
||
let PrismaClient, prisma | ||
|
||
const id = '4ccccccccccccccccccccccc' | ||
|
||
/** | ||
* Test aggregate operations on optional composite fields | ||
*/ | ||
describeIf(!process.env.TEST_SKIP_MONGODB)('aggregate > optional', () => { | ||
beforeAll(async () => { | ||
PrismaClient = await getTestClient('../') | ||
prisma = new PrismaClient() | ||
}) | ||
|
||
beforeEach(async () => { | ||
await prisma.commentOptionalProp.deleteMany({ where: { id } }) | ||
await prisma.commentOptionalProp.create({ | ||
data: { | ||
id, | ||
country: 'France', | ||
content: { | ||
set: { | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
afterEach(async () => { | ||
await prisma.$disconnect() | ||
}) | ||
|
||
/** | ||
* Simple aggregate | ||
*/ | ||
test('aggregate', async () => { | ||
const comment = await prisma.commentOptionalProp.aggregate({ | ||
where: { id }, | ||
orderBy: { | ||
content: { | ||
upvotes: { | ||
_count: 'desc', | ||
}, | ||
}, | ||
}, | ||
_count: true, | ||
}) | ||
|
||
expect(comment).toMatchInlineSnapshot(` | ||
Object { | ||
_count: 1, | ||
} | ||
`) | ||
}) | ||
}) |
63 changes: 63 additions & 0 deletions
63
packages/client/src/__tests__/integration/happy/composites-mongo/aggregate/required.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { getTestClient } from '../../../../../utils/getTestClient' | ||
|
||
const describeIf = (condition: boolean) => (condition ? describe : describe.skip) | ||
|
||
let PrismaClient, prisma | ||
|
||
const id = '5ccccccccccccccccccccccc' | ||
|
||
/** | ||
* Test aggregate operations on required composite fields | ||
*/ | ||
describeIf(!process.env.TEST_SKIP_MONGODB)('aggregate > required', () => { | ||
beforeAll(async () => { | ||
PrismaClient = await getTestClient('../') | ||
prisma = new PrismaClient() | ||
}) | ||
|
||
beforeEach(async () => { | ||
await prisma.commentRequiredProp.deleteMany({ where: { id } }) | ||
await prisma.commentRequiredProp.create({ | ||
data: { | ||
id, | ||
country: 'France', | ||
content: { | ||
set: { | ||
text: 'Hello World', | ||
upvotes: { | ||
vote: true, | ||
userId: '10', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
afterEach(async () => { | ||
await prisma.$disconnect() | ||
}) | ||
|
||
/** | ||
* Simple aggregate | ||
*/ | ||
test('aggregate', async () => { | ||
const comment = await prisma.commentRequiredProp.aggregate({ | ||
where: { id }, | ||
orderBy: { | ||
content: { | ||
upvotes: { | ||
_count: 'desc', | ||
}, | ||
}, | ||
}, | ||
_count: true, | ||
}) | ||
|
||
expect(comment).toMatchInlineSnapshot(` | ||
Object { | ||
_count: 1, | ||
} | ||
`) | ||
}) | ||
}) |
Oops, something went wrong.