Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the original @prisma/client module from jestPrisma #105

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

azoom-dang-minh-vuong
Copy link

An error occurred when using the raw database access method and building raw query with Prisma.sql tag function. Example below:

import { Prisma } from '@prisma/client'
const { client } = jestPrisma

const name = 'test'
const result = await client.$queryRaw`
  SELECT * FROM users
  ${Prisma.sql`WHERE name = ${name}`}
`

Error: Raw query failed. Code: 1064. Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? ....'

Cause: jest create worker that is a child process or a worker_thread (https://jestjs.io/docs/29.5/configuration#workerthreads). Worker will create a VM to execute the test file. The problem here is the @prisma/client module object in the worker is different with one in the VM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant