-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add support for exceptions thrown by ExecuteUpdate and ExecuteDelete #82
Conversation
Thanks for the PR @MarkusG! I agree, it's a good idea to process exception thrown by As for the implementation, what if there is a single class that implements |
That would require the interceptor to implement all methods, which would be a lot of extraneous code since all we want are As for |
I haven't tried it but these interfaces have Default interface methods so we would only implement the ones that we are interested in. |
Interesting. The documentation's suggestion to inherit from the classes if not implementing all methods made me think implementing the interfaces would require implementations for all methods. In that case, I think a single interceptor implementing both interfaces is a great idea. Right now I'm working on tests for all the exceptions for |
I saw there's a skipped SQLite test referencing an EF issue that has since been closed. I also noticed that SQLite appeared to not enforce the max length on a string. Do you have any insight into this @Giorgi? Oracle has a different error code for inserting vs. updating null into a not-null column, so I'll add support for that in another PR. |
The max length test is skipped because that EF Core issue was fixed in version 9. I'll re-enable that test when I upgrade to EF Core 9 Is the PR ready for review? |
24e0fe6
to
20f33c7
Compare
Ready for review. One question I still have is: Why is the |
Probably because I didn't want to make it public not to pollute the public API. |
That makes sense. It does make the |
I should have some time at the end of the week to review it. |
Looks good. I see that in many places method definitions and some code is split across multiple lines, you probably use ReSharper or another formatting tool. Can you put that code on the same lines as it was before? It makes it harder to read and see what's changed actually. |
Thanks! |
Update failures from
ExecuteUpdate()
andExecuteDelete()
and their async variants will not be intercepted bySaveChangesInterceptor
. To add support for errors thrown in this way, I have added aDbCommandInterceptor
. This required refactoring theDatabaseError
enum out of the interceptor class. As I understand it, this is not a breaking change.Addresses #81