-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(client): prototype referential integrity tests
Related: #10806 Test Suites: 1 failed, 1 total Tests: 3 failed, 45 passed, 48 total Snapshots: 0 total Time: 9.838 s
- Loading branch information
Showing
4 changed files
with
433 additions
and
0 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
47 changes: 47 additions & 0 deletions
47
packages/client/tests/functional/referential-integrity/_matrix.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,47 @@ | ||
import { defineMatrix } from '../_utils/defineMatrix' | ||
|
||
const RI = process.env.RI | ||
if (RI !== 'prisma' && RI !== 'foreignKeys') { | ||
throw new Error(`RI must be either "prisma" or "foreignKeys" but was "${RI}"`) | ||
} | ||
const referentialIntegrity: 'prisma' | 'foreignKeys' | '' = RI || '' | ||
|
||
export default defineMatrix(() => [ | ||
[ | ||
{ | ||
provider: 'postgresql', | ||
id: 'String @id', | ||
referentialIntegrity, | ||
}, | ||
{ | ||
provider: 'sqlite', | ||
id: 'String @id', | ||
referentialIntegrity, | ||
}, | ||
{ | ||
provider: 'mysql', | ||
id: 'String @id', | ||
referentialIntegrity, | ||
}, | ||
{ | ||
provider: 'sqlserver', | ||
id: 'String @id', | ||
referentialIntegrity, | ||
}, | ||
{ | ||
provider: 'cockroachdb', | ||
id: 'String @id', | ||
referentialIntegrity, | ||
}, | ||
{ | ||
provider: 'mongodb', | ||
id: 'String @id @map("_id") @db.ObjectId', | ||
referentialIntegrity: 'default', | ||
}, | ||
], | ||
[ | ||
{ | ||
previewFeatures: '"referentialIntegrity"', | ||
}, | ||
], | ||
]) |
47 changes: 47 additions & 0 deletions
47
packages/client/tests/functional/referential-integrity/prisma/_schema.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,47 @@ | ||
import testMatrix from '../_matrix' | ||
|
||
export default testMatrix.setupSchema(({ provider, previewFeatures, referentialIntegrity, id }) => { | ||
let referentialIntegrityLine = '' | ||
|
||
switch (referentialIntegrity) { | ||
case 'prisma': | ||
case 'foreignKeys': | ||
referentialIntegrityLine = `referentialIntegrity = "${referentialIntegrity}"` | ||
break | ||
default: | ||
break | ||
} | ||
|
||
return /* Prisma */ ` | ||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = [${previewFeatures}] | ||
} | ||
datasource db { | ||
provider = "${provider}" | ||
url = env("DATABASE_URI_${provider}") | ||
${referentialIntegrityLine} | ||
} | ||
model UserDefault { | ||
id ${id} | ||
profile ProfileDefault? | ||
} | ||
model ProfileDefault { | ||
id ${id} | ||
user UserDefault @relation(fields: [userId], references: [id]) | ||
userId String @unique | ||
} | ||
model UserCascade { | ||
id ${id} | ||
profile ProfileCascade? | ||
} | ||
model ProfileCascade { | ||
id ${id} | ||
user UserCascade @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade) | ||
userId String @unique | ||
} | ||
` | ||
}) |
Oops, something went wrong.