You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I try to perform a findFirst operation with a condition where "field": { is: null }, it automatically includes deletedAt: null in the query. Here is the code that reproduces the problem:
When you are querying for { is: null } I'm guessing it's to ensure the relation is unset right? If that is the case this is an interesting problem, because if the model at the other end of the relation is one configured for soft-delete then the query may result in incorrect results. For example if UserKey has been soft-deleted the relation between Key and UserKey still exists so { is: null } is not true, however you probably want it to treat the relation as if it was null right?
I think probably the best bet is to handle this case by changing { where: { is: null } } to the following or something similar:
I figured out a way out of this situation. Instead {"relation":{is:null}}, you can use {"relation":null} and it will work as expected. I didn't fully understand difference between null and is:null, only that is:null is newer. Using plain prisma with both cases i achieve the same result, so middleware should also work properly in both cases, i believe. This is a working query:
Whenever I try to perform a findFirst operation with a condition where "field": { is: null }, it automatically includes deletedAt: null in the query. Here is the code that reproduces the problem:
Here are the schema models:
And this is the error:
Expected Behavior
The query should be executed with only userKey: { is: null } without automatically including deletedAt: null.
Actual Behavior
The deletedAt: null condition is automatically added when userKey: { is: null } is used, causing an error.
Environment
Prisma-soft-delete-middleware version: 1.1.2
Prisma version: 5.2.0
Node.js version: 18.12.1
The text was updated successfully, but these errors were encountered: