Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: print getConfig warnings (#4124)
Related to prisma/prisma-client-js#898
- Loading branch information
1 parent
b26d836
commit d1e2e15
Showing
9 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/packages/client/src/__tests__/integration/happy/provider-array/.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 added
BIN
+56 KB
src/packages/client/src/__tests__/integration/happy/provider-array/dev.db
Binary file not shown.
37 changes: 37 additions & 0 deletions
37
src/packages/client/src/__tests__/integration/happy/provider-array/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,37 @@ | ||
datasource db { | ||
provider = ["postgresql", "sqlite"] | ||
url = "file:./dev.db" | ||
default = true | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
// / User model comment | ||
model User { | ||
id String @id @default(uuid()) | ||
email String @unique | ||
// / name comment | ||
name String? | ||
posts Post[] | ||
profile Profile? | ||
} | ||
|
||
model Profile { | ||
id String @id @default(cuid()) | ||
bio String? | ||
user User @relation(fields: [userId], references: [id]) | ||
userId String @unique | ||
} | ||
|
||
model Post { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
published Boolean | ||
title String | ||
content String? | ||
authorId String? @map("author") | ||
author User? @relation(fields: [authorId], references: [id]) | ||
} |
30 changes: 30 additions & 0 deletions
30
src/packages/client/src/__tests__/integration/happy/provider-array/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,30 @@ | ||
import { getTestClient } from '../../../../utils/getTestClient' | ||
|
||
test('provider-array', async () => { | ||
const warnings: any[] = [] | ||
const oldWarn = console.warn | ||
console.warn = (...args) => { | ||
warnings.push(args) | ||
} | ||
const PrismaClient = await getTestClient() | ||
const prisma = new PrismaClient() | ||
const users = await prisma.user.findMany() | ||
await prisma.$disconnect() | ||
expect(users).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
email: a@a.de, | ||
id: 576eddf9-2434-421f-9a86-58bede16fd95, | ||
name: Alice, | ||
}, | ||
] | ||
`) | ||
expect(warnings).toMatchInlineSnapshot(` | ||
Array [ | ||
Array [ | ||
warn Using multiple providers is now deprecated. You should use a single provider instead. Read more at https://pris.ly/multi-provider-deprecation, | ||
], | ||
] | ||
`) | ||
console.warn = oldWarn | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import chalk from "chalk" | ||
|
||
export function printConfigWarnings(warnings: string[]) { | ||
if (warnings && warnings.length > 0) { | ||
const message = warnings.map(warning => `${chalk.yellow('warn')} ${warning}`).join('\n') | ||
console.warn(message) | ||
} | ||
} |