Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Tim Suchanek <Tim.Suchanek@gmail.com> Co-authored-by: William Luke <william@ordino.ai> Co-authored-by: William Luke <william@atto-byte.com>
- Loading branch information
1 parent
50e88b0
commit 59cf156
Showing
24 changed files
with
1,039 additions
and
287 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 |
---|---|---|
|
@@ -59,7 +59,7 @@ describe('aggregate', () => { | |
select: { | ||
count: { | ||
select: { | ||
_all: true, | ||
$all: true, | ||
}, | ||
}, | ||
}, | ||
|
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
1 change: 1 addition & 0 deletions
1
src/packages/client/src/__tests__/integration/happy/count/.gitignore
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 @@ | ||
!dev.db |
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
src/packages/client/src/__tests__/integration/happy/count/schema.prisma
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,30 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = "file:dev.db" | ||
default = true | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
// / User model comment | ||
model User { | ||
id String @default(uuid()) @id | ||
email String @unique | ||
age Int | ||
// / name comment | ||
name String? | ||
posts Post[] | ||
} | ||
|
||
model Post { | ||
id String @default(cuid()) @id | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
published Boolean | ||
title String | ||
content String? | ||
authorId String? | ||
author User? @relation(fields: [authorId], references: [id]) | ||
} |
64 changes: 64 additions & 0 deletions
64
src/packages/client/src/__tests__/integration/happy/count/test.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,64 @@ | ||
import { getTestClient } from '../../../../utils/getTestClient' | ||
|
||
test('count', async () => { | ||
const PrismaClient = await getTestClient() | ||
const prisma = new PrismaClient() | ||
const result = await prisma.user.count() | ||
expect.assertions(4) | ||
expect(result).toMatchInlineSnapshot(`10`) | ||
|
||
const result2 = await prisma.user.count({ | ||
select: true, | ||
}) | ||
expect(result2).toMatchInlineSnapshot(`10`) | ||
|
||
const result3 = await prisma.user.count({ | ||
select: { | ||
$all: true, | ||
email: true, | ||
age: true, | ||
name: true, | ||
}, | ||
}) | ||
expect(result3).toMatchInlineSnapshot(` | ||
Object { | ||
$all: 10, | ||
age: 10, | ||
email: 10, | ||
name: 10, | ||
} | ||
`) | ||
try { | ||
const result4 = await prisma.user.count({ | ||
select: { | ||
$all: true, | ||
email: true, | ||
age: true, | ||
name: true, | ||
posts: true, | ||
}, | ||
}) | ||
} catch (err) { | ||
expect(err.message).toMatchInlineSnapshot(` | ||
Invalid \`prisma.user.aggregate()\` invocation: | ||
{ | ||
count: { | ||
? $all?: true, | ||
? email?: true, | ||
? age?: true, | ||
? name?: true, | ||
posts: true, | ||
~~~~~ | ||
? id?: true | ||
} | ||
} | ||
Unknown field \`posts\` for select statement on model UserCountAggregateOutputType. Available options are listed in green. Did you mean \`id\`? | ||
`) | ||
} | ||
prisma.$disconnect() | ||
}) |
Oops, something went wrong.