Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineMatrix } from '../../_utils/defineMatrix' | ||
|
||
export default defineMatrix(() => [ | ||
[ | ||
{ | ||
provider: 'mongodb', | ||
}, | ||
], | ||
]) |
19 changes: 19 additions & 0 deletions
19
packages/client/tests/functional/issues/13089/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,19 @@ | ||
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 users { | ||
id String @id @map("_id") @default(auto()) @db.ObjectId | ||
firstName String @unique | ||
} | ||
` | ||
}) |
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,65 @@ | ||
import testMatrix from './_matrix' | ||
// @ts-ignore | ||
import type { PrismaClient } from './node_modules/@prisma/client' | ||
|
||
declare let prisma: PrismaClient | ||
|
||
// https://github.com/prisma/prisma/issues/13089 | ||
testMatrix.setupTestSuite( | ||
() => { | ||
beforeAll(async () => { | ||
await prisma.users.create({ | ||
data: { | ||
firstName: 'foo', | ||
}, | ||
}) | ||
|
||
await prisma.users.create({ | ||
data: { | ||
firstName: '$foo', | ||
}, | ||
}) | ||
}) | ||
|
||
test('should return records when using a `$` in the search string', async () => { | ||
const records = await prisma.users.findMany({ | ||
where: { | ||
firstName: '$foo', | ||
}, | ||
}) | ||
|
||
expect(records).toHaveLength(1) | ||
expect(records[0].firstName).toEqual('$foo') | ||
}) | ||
|
||
test('should update records when using a `$` in the search string', async () => { | ||
const record = await prisma.users.update({ | ||
where: { | ||
firstName: '$foo', | ||
}, | ||
data: { | ||
firstName: '$$foo', | ||
}, | ||
select: { | ||
firstName: true, | ||
}, | ||
}) | ||
|
||
expect(record.firstName).toEqual('$$foo') | ||
}) | ||
|
||
test('should delete records when using a `$` in the search string', async () => { | ||
await prisma.users.delete({ | ||
where: { | ||
firstName: '$$foo', | ||
}, | ||
}) | ||
}) | ||
}, | ||
{ | ||
optOut: { | ||
from: ['cockroachdb', 'mysql', 'postgresql', 'sqlite', 'sqlserver'], | ||
reason: 'Only applicable to Mongodb', | ||
}, | ||
}, | ||
) |