Skip to content
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

Made use of the proper ConflictingEntityException and ObjectNotFoundE… #191

Merged
merged 1 commit into from
May 21, 2021

Conversation

JanDoerrenhaus
Copy link
Contributor

…xception on those use cases, and introduced try-with-resources for the used DslContext.

…xception on those use cases, and introduced try-with-resources for the used DslContext.
@sonarcloud
Copy link

sonarcloud bot commented May 17, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@lesmou lesmou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add to discussion.

{
return DslContexts.obtain(mizoolConnectionProvider).executeDelete(record);
int deletedRows = dslContext.executeDelete(record);
if (deletedRows != 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changing the behaviour in situations where we want to delete rows but none are present.
I am still not comfortable with that approach to handle these situations as erroneous since during a regular cleanup there might be a delete operation on already empty tables. I recall having that discussion already once but do not remember the outcome.
What are your thoughts? @JanDoerrenhaus @bannmann

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, we have been following the pattern, that if you DELETE an item that does not exist, a 404 is returned, not a 200. This class is meant to be used for the standard CRUD operations of REST stacks, not generically for each and every SQL delete that may ever happen. So if I see a "regular cleanup" using this class, I would question the sanity of the author.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Jan said.

Sure, there are cases where we don't care if rows were already deleted (or never existed in the first place). For those cases, we simply create a separate store with a behavior-revealing name (maybe FooCleanupStore or FooEnsureNoneExistStore for a Foo table).

@bannmann bannmann merged commit d40146a into develop May 21, 2021
@bannmann bannmann deleted the feature/proper-try-with-resources-and-exceptions branch May 21, 2021 07:57
@bannmann
Copy link
Contributor

FYI @gregorxiv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants