Make update method return Option[Row] instead of Boolean for all database libraries#139
Merged
oyvindberg merged 2 commits intomainfrom Jul 28, 2025
Merged
Make update method return Option[Row] instead of Boolean for all database libraries#139oyvindberg merged 2 commits intomainfrom
oyvindberg merged 2 commits intomainfrom
Conversation
|
Is there any work remaining here to be able to merge? Maybe I can help? |
Collaborator
Author
|
Yes, there is one bothersome thing. It should be completely fine for anorm now, but unfortunately there are two more libraries supported, and they should be in sync. The changes from Feel free to ping me if you decide to try and get stuck |
fddba55 to
5e995ff
Compare
…base libraries - Changed update method signature to return Option[Row] using PostgreSQL RETURNING clause - Applied changes to all three database libraries: - Anorm: Uses executeInsert with singleOpt parser - Doobie: Uses query with option combinator - ZIO-JDBC: Uses query with selectOne - Updated all tests to verify the returned Option contains expected values - Updated mock implementations to return the row instead of boolean This provides better feedback about what was actually updated and enables verification that the update was applied correctly.
7c04c41 to
cd64548
Compare
cd64548 to
f6edf8a
Compare
f6edf8a to
2385ab0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR changes the
updatemethod in all database libraries to returnOption[Row]instead ofBoolean, providing better feedback about what was actually updated.Changes
update(row: Row): Boolean→update(row: Row): Option[Row]RETURNINGclauseexecuteInsertwithsingleOptparser.query(using RowType.read).option.query(jdbcDecoder).selectOneOptioncontains expected valuesBenefits
Breaking Change
This is a breaking change for users of the
updatemethod. Migration is straightforward:Test plan
Implementation Complete
All three database libraries have been updated and tested. The implementation is ready for review.