micronaut-projects / micronaut-projects/micronaut-data
Update fails to detected when record not found for update
- Dominant language
- Java
- Stars
- 482
- Forks
- 229
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 32
Description
Sorry, but I don't have an example project for this issue. Let me know if you need one.
In the DefaultJdbcRepositoryOperations.update() method, it does not check the result of the ps.executeUpdate() to verify that the record was really updated.
If another process deletes the record, then the update will silently fail. That would be a big problem for my type of application.
Could you throw a 'record not found' exception of some sort? As an alternative, you could have the method return null when the update does not affect any records. I could detect that too.
I assume a simple check for result<>1 would be Ok. I don't know if you will need to make this configurable. I don't need it to be configurable.
Thanks.
Contributor guide
Research direction
Start in the DefaultJdbcRepositoryOperations.update() method and inspect how the result of ps.executeUpdate() is currently handled. Reproduce or reason about an update after the record has been deleted, then clarify whether the expected result is an exception or a null return. Done means an update affecting no records is detectable without silently succeeding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100