Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88fae09
commit 12780e8
Showing
8 changed files
with
264 additions
and
314 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/packages/client/src/__tests__/integration/errors/uncheckedScalarValidation/.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-tmp.db |
Binary file added
BIN
+48 KB
src/packages/client/src/__tests__/integration/errors/uncheckedScalarValidation/dev.db
Binary file not shown.
92 changes: 92 additions & 0 deletions
92
src/packages/client/src/__tests__/integration/errors/uncheckedScalarValidation/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,92 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["uncheckedScalarInputs"] | ||
} | ||
|
||
datasource db { | ||
provider = "sqlite" | ||
url = "file:dev.db" | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
uuid String @default(uuid()) | ||
email String @unique | ||
firstName String | ||
lastName String | ||
password String | ||
status Boolean @default(true) | ||
locked Boolean @default(false) | ||
public Boolean @default(true) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
trips Trip[] | ||
activities UsersToActivities[] | ||
} | ||
|
||
model Trip { | ||
id Int @id @default(autoincrement()) | ||
uuid String @default(uuid()) | ||
userId Int | ||
name String | ||
description String? | ||
public Boolean | ||
dateFrom DateTime | ||
dateTo DateTime | ||
adults Int | ||
children Int? @default(0) | ||
infants Int? @default(0) | ||
backgroundUrl String? | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
user User @relation(fields: [userId], references: [id]) | ||
activities Activity[] | ||
@@unique([userId, id]) | ||
} | ||
|
||
model Activity { | ||
id Int @id @default(autoincrement()) | ||
uuid String @default(uuid()) | ||
tripId Int | ||
activityTypeId Int | ||
name String | ||
description String? | ||
location String | ||
date DateTime | ||
timezone String | ||
public Boolean | ||
maxPeople Int? @default(0) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
trip Trip @relation(fields: [tripId], references: [id]) | ||
activityType ActivityType @relation(fields: [activityTypeId], references: [id]) | ||
users UsersToActivities[] | ||
@@unique([tripId, id]) | ||
} | ||
|
||
model ActivityType { | ||
id Int @id @default(autoincrement()) | ||
uuid String @default(uuid()) | ||
name String | ||
type String @unique | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
activities Activity[] | ||
} | ||
|
||
model UsersToActivities { | ||
userId Int | ||
activityId Int | ||
createdAt DateTime @default(now()) | ||
user User @relation(fields: [userId], references: [id]) | ||
activity Activity @relation(fields: [activityId], references: [id]) | ||
@@id([userId, activityId]) | ||
} |
96 changes: 96 additions & 0 deletions
96
src/packages/client/src/__tests__/integration/errors/uncheckedScalarValidation/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,96 @@ | ||
import { getTestClient } from '../../../../utils/getTestClient' | ||
|
||
test('uncheckedScalarInputs validation', async () => { | ||
expect.assertions(1) | ||
const PrismaClient = await getTestClient() | ||
const prisma = new PrismaClient() | ||
|
||
try { | ||
await prisma.trip.create({ | ||
data: { | ||
name: 'Trip 1', | ||
description: 'This is a description', | ||
public: false, | ||
dateFrom: new Date('2020-12-29T10:15:16.495Z'), | ||
dateTo: new Date('2020-12-29T10:15:16.495Z'), | ||
adults: 12, | ||
backgroundUrl: 'https://duckduckgo.com', | ||
userId: 1, | ||
activities: { | ||
create: [ | ||
{ | ||
name: 'Activity1', | ||
description: 'This is activity 1', | ||
location: 'Some location', | ||
date: new Date('2020-12-29T10:15:16.495Z'), | ||
public: false, | ||
timezone: 'Europe/Berlin', | ||
maxPeople: 1, | ||
activityTypeId: 1, | ||
tripId: 1, | ||
}, | ||
], | ||
}, | ||
}, | ||
}) | ||
} catch (e) { | ||
expect(e).toMatchInlineSnapshot(` | ||
Invalid \`prisma.trip.create()\` invocation in | ||
/client/src/__tests__/integration/errors/uncheckedScalarValidation/test.ts:9:23 | ||
6 const prisma = new PrismaClient() | ||
7 | ||
8 try { | ||
→ 9 await prisma.trip.create({ | ||
data: { | ||
name: 'Trip 1', | ||
description: 'This is a description', | ||
public: false, | ||
dateFrom: new Date('2020-12-29T10:15:16.495Z'), | ||
dateTo: new Date('2020-12-29T10:15:16.495Z'), | ||
adults: 12, | ||
backgroundUrl: 'https://duckduckgo.com', | ||
userId: 1, | ||
activities: { | ||
create: [ | ||
{ | ||
name: 'Activity1', | ||
description: 'This is activity 1', | ||
location: 'Some location', | ||
date: new Date('2020-12-29T10:15:16.495Z'), | ||
public: false, | ||
timezone: 'Europe/Berlin', | ||
maxPeople: 1, | ||
activityTypeId: 1, | ||
tripId: 1 | ||
~~~~~~ | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
Unknown arg \`tripId\` in data.activities.create.0.tripId for type ActivityUncheckedCreateWithoutTripInput. Did you mean \`id\`? Available args: | ||
type ActivityUncheckedCreateWithoutTripInput { | ||
id?: Int | ||
uuid?: String | ||
activityTypeId: Int | ||
name: String | ||
description?: String | Null | ||
location: String | ||
date: DateTime | ||
timezone: String | ||
public: Boolean | ||
maxPeople?: Int | Null | ||
createdAt?: DateTime | ||
updatedAt?: DateTime | ||
users?: UsersToActivitiesUncheckedCreateManyWithoutActivityInput | ||
} | ||
`) | ||
} | ||
|
||
prisma.$disconnect() | ||
}) |
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
Oops, something went wrong.