forked from prisma/prisma
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): delete transactionId field in middleware (prisma#7662)
Co-authored-by: William Luke <william@ordino.ai> Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
- Loading branch information
1 parent
881800b
commit 9df0b38
Showing
6 changed files
with
109 additions
and
38 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/packages/client/src/__tests__/integration/happy/middlewares-transaction/.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
+52 KB
src/packages/client/src/__tests__/integration/happy/middlewares-transaction/dev.db
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
src/packages/client/src/__tests__/integration/happy/middlewares-transaction/package.json
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,12 @@ | ||
{ | ||
"name": "my-prisma-project", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
28 changes: 28 additions & 0 deletions
28
src/packages/client/src/__tests__/integration/happy/middlewares-transaction/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,28 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = "file:dev.db" | ||
} | ||
|
||
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[] | ||
} | ||
|
||
model Post { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
published Boolean | ||
title String | ||
content String? | ||
authorId String? | ||
author User? @relation(fields: [authorId], references: [id]) | ||
} |
35 changes: 35 additions & 0 deletions
35
src/packages/client/src/__tests__/integration/happy/middlewares-transaction/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,35 @@ | ||
import { getTestClient } from '../../../../utils/getTestClient' | ||
|
||
describe('middleware and transaction', () => { | ||
test('typeof await next()', async () => { | ||
const PrismaClient = await getTestClient() | ||
|
||
const prisma = new PrismaClient() | ||
await prisma.user.deleteMany() | ||
|
||
const responses: any[] = [] | ||
prisma.$use(async (params, next) => { | ||
const response = await next(params) | ||
responses.push(response) | ||
return response | ||
}) | ||
|
||
await prisma.$transaction([ | ||
prisma.user.create({ | ||
data: { | ||
email: 'test@test.com', | ||
name: 'test', | ||
}, | ||
}), | ||
]) | ||
expect(typeof responses[0]).toEqual(`object`) | ||
expect(responses[0].email).toMatchInlineSnapshot(`test@test.com`) | ||
|
||
const users = await prisma.user.findMany() | ||
expect(users[0].email).toMatchInlineSnapshot(`test@test.com`) | ||
|
||
await prisma.user.deleteMany() | ||
|
||
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