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

queryRaw Error when calling SP or Function #2679

Closed
nicosampler opened this issue Jun 6, 2020 · 6 comments · Fixed by prisma/prisma-engines#798
Closed

queryRaw Error when calling SP or Function #2679

nicosampler opened this issue Jun 6, 2020 · 6 comments · Fixed by prisma/prisma-engines#798
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli
Milestone

Comments

@nicosampler
Copy link

When I try to get the results for an SP or a function like:

queryRaw("CALL increaseShopCounter()"); or queryRaw("select callIncreaseShopCounter();")

it fails with an undescriptive message:

prisma:query select callIncreaseShopCounter(
        15, 
        79,
        5
      ) as issuedId
PrismaClientKnownRequestError: Raw query failed. Code: `N/A`. Message: `N/A`
    at PrismaClientFetcher.request (/home/nicosampler/develop/cauda/node_modules/@prisma/client/runtime/index.js:1:148505)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 'P2010',
  meta: { code: 'N/A', message: 'N/A' }
}

Both SP and Function return values when executing them directly.

DB: MySql
Prisma:
"@prisma/cli": "^2.0.0-beta.8",
"@prisma/client": "^2.0.0-beta.8",

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli labels Jun 8, 2020
@timsuchanek
Copy link
Contributor

Thanks @nicosampler !
Please try using executeRaw instead. This happens, because your query probably doesn't return rows, then the db driver errors.
We will improve the error message here.

@ramirotw
Copy link

ramirotw commented Jun 8, 2020

I'm seeing the same behavior calling a stored procedure that runs some updates/inserts and then return results, I can't use executeRaw as I need the results back and queryRaw fails without much info.

@pimeys pimeys self-assigned this Jun 9, 2020
@pimeys
Copy link
Contributor

pimeys commented Jun 9, 2020

Need to see if something is broken in the underlying MySQL crate. At least we need better error messages here.

@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Jun 10, 2020
@nicosampler
Copy link
Author

just to be sure, queryRaw should be able to return results from SP or functions calls in the same way it works for normal selects from tables?

@janpio janpio added this to the 2.1.0 milestone Jun 10, 2020
@pimeys
Copy link
Contributor

pimeys commented Jun 10, 2020

Yeah, if some data comes out.

This is now appointed for the next milestone so I'll start looking into it.

@pimeys
Copy link
Contributor

pimeys commented Jun 11, 2020

Tested:

DELIMITER $$
CREATE PROCEDURE FooBar() BEGIN SELECT 1; END$$
DELIMITER ;

using queryRaw with CALL FooBar(), returns row with one column, holding the value 1. Should be fixed in the dev releases, available later today. Or in 2.1.0, coming in a few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants