-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[BREAKING CHANGE] Disconnect/connect (for relations) throws errors needlessly #5005
Comments
When finally deciding what the behavior should be, you should also take into consideration how Photon will ensure a working connection when running on serverless infrastructure, especially after a frozen function is resumed. In the best case this just happens automatically. Besides that I also wouldn't expect it to throw. As stated by @jhalborg the requested state is the current state. Otherwise I currently can't think of a real case where a developer has to call connect when he is already connected to a database. Only with bad state management or if a disconnect has failed somehow. Nevertheless my opinion is that Photon shouldn't throw but instead log a warning which informs the developer that a call to connect/disconnect would not have been needed. |
This not a bug as this is the intended behavior. Therefore marking it as a feature request. @sorenbs is the owner of the spec for this API. He should make a call whether we want to change this behavior. |
@jhalborg You are right, I have indeed not paid enough attention and misunderstood it. But still I have the same opinion for connecting/disconnecting relations: It shouldn't throw an error and in this case even no warning. I don't know what exactly the Prisma Query Engine is doing, but I think when doing the same operation in raw SQL it also wouldn't throw an error. Am I right about this? Maybe a comparable situation of real life that just came to my mind is that: |
Internal Note: This might make sense, but we don't have time to think about it right now. |
@janpio - Wouldn't it make sense to spend time on this before GA of the client, as it would otherwise lead to a lot of error-handling code for users of the library that shouldn't be necessary, and that would have to be removed if this is implemented later on? I think it'll save your users a lot of code, time and confusion. |
Certainly, but we can not do all the things that would make sense right now, so we have to make decisions where to focus on. Fixing real bugs and finishing functionality that is needed currently is higher on that list. But we will get to this. |
Hey @jhalborg, I re-wrote your initial problem statement. I hope you don't mind! |
When can we expect this done, please? |
Next Step:
|
This works now, if you try to connect an already connected relation, it's a no-op. |
Problem
Currently when you try to connect or disconnect relationships, you need to be needlessly cautious that you haven't done it before, otherwise the command will throw.
It's weird that it throws, seeing as the state of the data afterwards is as the request wanted it in the first place anyway.
Here's an example:
The same applies for disconnect.
Additional Context: https://prisma.slack.com/archives/CKQTGR6T0/p1568120850240700?thread_ts=1567958862.225000&cid=CKQTGR6T0
Suggested Solution
Don't throw. Allow connects and disconnects to either apply the change or ignore the action.
The text was updated successfully, but these errors were encountered: