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
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/client/tests/functional/issues/21352-id-does-not-exist/_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,21 @@ | ||
import { defineMatrix } from '../../_utils/defineMatrix' | ||
|
||
export default defineMatrix(() => [ | ||
[ | ||
{ | ||
provider: 'sqlite', | ||
}, | ||
{ | ||
provider: 'postgresql', | ||
}, | ||
{ | ||
provider: 'mysql', | ||
}, | ||
{ | ||
provider: 'cockroachdb', | ||
}, | ||
{ | ||
provider: 'sqlserver', | ||
}, | ||
], | ||
]) |
37 changes: 37 additions & 0 deletions
37
packages/client/tests/functional/issues/21352-id-does-not-exist/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 { foreignKeyForProvider, 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 User1 { | ||
email ${idForProvider(provider)} | ||
relation1 Relation1[] | ||
} | ||
model Relation1 { | ||
id ${idForProvider(provider)} | ||
user User1 @relation(fields: [email], references: [email]) | ||
email ${foreignKeyForProvider(provider)} | ||
} | ||
model User2 { | ||
id ${idForProvider(provider)} | ||
relation2 Relation2[] | ||
} | ||
model Relation2 { | ||
field ${idForProvider(provider)} | ||
user User2 @relation(fields: [email], references: [id]) | ||
email ${foreignKeyForProvider(provider)} | ||
} | ||
` | ||
}) |
45 changes: 45 additions & 0 deletions
45
packages/client/tests/functional/issues/21352-id-does-not-exist/tests.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,45 @@ | ||
import testMatrix from './_matrix' | ||
// @ts-ignore | ||
import type { PrismaClient } from './node_modules/@prisma/client' | ||
|
||
declare let prisma: PrismaClient | ||
|
||
testMatrix.setupTestSuite( | ||
() => { | ||
// TODO: this currently fails with "The column `j1.id` does not exist in the current database.". | ||
// Close https://github.com/prisma/prisma/issues/21352 once fixed. | ||
test('[1] should not fail', async () => { | ||
await prisma.relation1.findMany({ | ||
select: { | ||
id: true, | ||
}, | ||
where: { | ||
user: { | ||
email: 'info@example.com', | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
// TODO: this currently fails with "The column `j1.field` does not exist in the current database.". | ||
// Close https://github.com/prisma/prisma/issues/21352 once fixed. | ||
test('[2] should not fail', async () => { | ||
await prisma.relation2.findMany({ | ||
select: { | ||
field: true, | ||
}, | ||
where: { | ||
user: { | ||
id: 'info@example.com', | ||
}, | ||
}, | ||
}) | ||
}) | ||
}, | ||
{ | ||
optOut: { | ||
from: ['mongodb'], | ||
reason: 'Only SQL databases were affected by regression #21352', | ||
}, | ||
}, | ||
) |