Skip to content

Commit

Permalink
test(client): Regression test for gh-13089 (#15435)
Browse files Browse the repository at this point in the history
  • Loading branch information
danstarns committed Sep 23, 2022
1 parent c4bc1c7 commit 8bbead4
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/client/tests/functional/issues/13089/_matrix.ts
@@ -0,0 +1,9 @@
import { defineMatrix } from '../../_utils/defineMatrix'

export default defineMatrix(() => [
[
{
provider: 'mongodb',
},
],
])
19 changes: 19 additions & 0 deletions packages/client/tests/functional/issues/13089/prisma/_schema.ts
@@ -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
}
`
})
65 changes: 65 additions & 0 deletions packages/client/tests/functional/issues/13089/tests.ts
@@ -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',
},
},
)

0 comments on commit 8bbead4

Please sign in to comment.