$queryRaw generates +1 other queries for every middleware
See original GitHub issueBug description
The prisma.$queryRaw()
command generates 4 queries instead of 1.
How to reproduce
$queryRaw()
generates 4 queries for one operation!? My example:
await prisma.$queryRaw`SELECT id FROM public.user`
Log output:
prisma:query SELECT id FROM public.user
prisma:query SELECT id FROM public.user
prisma:query SELECT id FROM public.user
prisma:query SELECT id FROM public.user
Expected behavior
It should generate 1 query for 1 operation
Prisma information
model User {
id Int @id @default(autoincrement())
}
I have 4 middleware functions.
Environment & setup
- OS: Windows
- Database: PostgreSQL
- Node.js version: v16.13.1
Prisma Version
"^3.8.1"
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Raw database access (Reference) - Prisma
$queryRaw returns actual database records. For example, the following SELECT query returns all fields for each record in the User table:.
Read more >Query Builder - Laravel - The PHP Framework For Web Artisans
Laravel's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database ......
Read more >Raw Queries - Sequelize
Several other query types are available. ... await sequelize.query('SELECT 1', { ... Will get called for every SQL query that gets sent
Read more >node.js - execute Middleware function for all query middlewares
looks like there is no such possibility. you might construct it dynamically. you could grab a list of methods here: ...
Read more >SQL Queries - EF Core - Microsoft Learn
Using SQL queries in Entity Framework Core. ... since databases do not allow parameterizing column names (or any other part of the schema)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you very much for your support! Yes, it did work out. If you and your team at Prisma continue to provide such an amazing support, you will definitely make a difference. It shows that you are interested in each user’s issue, and changes the experience all together.
Ok, got it:
Your middlewares are all calling this method as their first action - and on a raw query
params.model
is indeed undefined and you already trigger the query by callingnext
. Then later at the end of the middleware you callnext
again.Does that make sense?