Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(adapter-d1): use
changes
instead of rows_written
Because `rows_written` also counts the writes to an index. Fixes #23902 Closes prisma/team-orm#1069
- Loading branch information
Showing
4 changed files
with
87 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { defineMatrix } from '../../_utils/defineMatrix' | ||
import { allProviders } from '../../_utils/providers' | ||
|
||
export default defineMatrix(() => [allProviders]) |
37 changes: 37 additions & 0 deletions
37
packages/client/tests/functional/issues/23902/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,37 @@ | ||
import { idForProvider } from '../../../_utils/idForProvider' | ||
import testMatrix from '../_matrix' | ||
|
||
export default testMatrix.setupSchema(({ provider }) => { | ||
return /* Prisma */ ` | ||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
datasource db { | ||
provider = "${provider}" | ||
url = env("DATABASE_URI_${provider}") | ||
} | ||
model User { | ||
id ${idForProvider(provider)} | ||
email String @unique | ||
name String? | ||
posts Post[] | ||
} | ||
model Post { | ||
id ${idForProvider(provider)} | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
title String | ||
content String? | ||
published Boolean @default(false) | ||
viewCount Int @default(0) | ||
author User? @relation(fields: [authorId], references: [id]) | ||
authorId String? | ||
// This is the most important part of the test | ||
@@index([authorId]) | ||
} | ||
` | ||
}) |
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,45 @@ | ||
import testMatrix from './_matrix' | ||
// @ts-ignore | ||
import type { PrismaClient } from './node_modules/@prisma/client' | ||
|
||
declare let prisma: PrismaClient | ||
|
||
// https://github.com/prisma/prisma/issues/4004 | ||
testMatrix.setupTestSuite(() => { | ||
test('should not throw error when updating fields on a many to many join table', async () => { | ||
const post = await prisma.post.create({ | ||
data: { | ||
title: 'Hello World', | ||
}, | ||
}) | ||
|
||
expect(post).toMatchObject({ | ||
authorId: null, | ||
content: null, | ||
createdAt: expect.any(Date), | ||
id: expect.any(String), | ||
published: false, | ||
title: 'Hello World', | ||
updatedAt: expect.any(Date), | ||
viewCount: 0, | ||
}) | ||
|
||
await expect( | ||
prisma.user.create({ | ||
data: { | ||
email: 'test@example.com', | ||
name: 'Test', | ||
posts: { | ||
connect: { | ||
id: post.id, | ||
}, | ||
}, | ||
}, | ||
}), | ||
).resolves.toMatchObject({ | ||
email: 'test@example.com', | ||
id: expect.any(String), | ||
name: 'Test', | ||
}) | ||
}) | ||
}) |