question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

executeRaw error: PrismaClientKnownRequestError: Raw query failed. Code: `N/A`. Message: `N/A` when executing successful create queries

See original GitHub issue

Bug description

If a query that does not return results is ran with db.executeRaw, it throws the following error:

PrismaClientKnownRequestError: Raw query failed. Code: `N/A`. Message: `N/A`
    at PrismaClientFetcher.request (D:\dev\perimetre\export-connect-backend\node_modules\@prisma\client\src\runtime\getPrismaClient.ts:902:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 'P2010',
  meta: { code: 'N/A', message: 'N/A' }
}

But even thought I get an exception, the query still runs successfully and the database is modified correctly.

An example of the query that It’s being ran:

CREATE TABLE IF NOT EXISTS `MyTable` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `MyTable.slug` (`slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

This also happenned when running a select query with queryRaw and the table did not have any data. I got the error instead of getting an undefined result or an empty array.

How to reproduce

  1. Make a simple create query like the one in the example above
  2. Execute it with db.executeRaw

Expected behavior

The expected behaviour should be that no exception is thrown since the operation worked successfully

Environment & setup

  • OS: Windows 10
  • Database: Mysql 8
  • Prisma version: 2.1.3
  • Node.js version: v12.18.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
eldoncosta1commented, May 20, 2022

remove quotes inside SQL command, leave just

AND YEAR(date_facture) = ${annee} AND MONTH(date_facture) = ${mois} AND MONTH(date_facture) = ${mois}

0reactions
janpiocommented, Mar 11, 2022

Please open a new discussion or bug report @mjpaquet. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma Client API (Reference)
In this situation, one of the operations succesfully creates the new record but the other operations fail and return a unique key constraint...
Read more >
prisma $queryRaw doesn't work with single quotes in the ...
queryRaw()` invocation: Your raw query had an incorrect number of parameters. Expected: `1`, actual: `2`. code: 'P1016', ...
Read more >
After upgrading to version3 0 2 I get error for queryRaw Pri
After upgrading to version3.0.2 I get error for queryRaw: PrismaClientKnownRequestError: Invalid `prisma.queryRaw()` invocation: Raw query ...
Read more >
Prisma Versions
Interactive transactions allow you to pass an async function into a $transaction , and execute any code you like between the individual Prisma...
Read more >
Highlights - FeedsAnywhere
There are no nested queries in the upsert 's create and update options ... The error message will now be more useful (...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found