Select none in update
See original GitHub issueProblem
Currently an update
is quite slow because it does 3 steps:
- Select my thing
- Update my thing
- Select my thing
I do understand the need for the first select to make sure it updates only one record, but the last one if a bit annoying.
Suggested solution
It was suggested elsewhere that it could be using a RETURNING
/other similar clause to remove the last one.
This would be nice, but my understanding is that it is an important change.
I suggest as a first step to allow users to tell prisma to not return anything.
This would need a new keyword in select
, I suggest none
:
prisma.myThing.update({
data: { ... },
where: { id: 1 },
select: { none: true }
})
Alternatives
You can use an updateMany
to avoid the second select
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Update field as null from a select that returns 0 rows
I am trying to update a field with a null value when the select doesn't return values. Eg: UPDATE table SET title =...
Read more >How to UPDATE from a SELECT statement in SQL Server
UPDATE queries can change all tables' rows, or we can limit the update statement affects for certain rows with the help of the...
Read more >How to Replace Nulls with 0s in SQL - The Data School
Null Values can be replaced in SQL by using UPDATE, SET, and WHERE to search a column in a table for nulls and...
Read more >What is SELECT FOR UPDATE in SQL (with examples)?
SELECT FOR UPDATE is a SQL command that's useful in the context of transactional workloads. It allows you to “lock” the rows returned...
Read more >Documentation: 15: INSERT - PostgreSQL
However, ON CONFLICT DO UPDATE also requires SELECT privilege on any ... ON CONFLICT DO NOTHING simply avoids inserting a row as its...
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 Free
Top 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
https://www.prisma.io/docs/concepts/components/prisma-client/null-and-undefined ☝️ The docs state:
So, you can achieve the behavior you’re looking for by writing:
Hope this helps 😃
no updates on this? seems like its been an issue for a while now