feat: [#358] Optimize the difference between db and orm#930
Merged
Conversation
Contributor
There was a problem hiding this comment.
PR Overview
This PR optimizes the differences between the database and ORM layers by updating function signatures and return types to use the new db interfaces consistently. Key changes include:
- Changing the function signatures of OrWhereBetween and OrWhereNotBetween from using a slice of values to explicitly passing two arguments (x and y).
- Updating the Update and Delete methods (and their mocks) to return *db.Result instead of *orm.Result.
- Adjusting interface definitions in contracts and mocks to reflect the new types and parameters.
Reviewed Changes
| File | Description |
|---|---|
| database/db/query_test.go | Updated tests to invoke Between methods with explicit x, y arguments. |
| database/db/query.go | Modified OrWhereBetween, OrWhereNotBetween, and Update signatures. |
| mocks/database/db/Query.go | Adjusted mock implementations to match new function signatures. |
| contracts/database/orm/orm.go | Updated method return types from orm.Result to db.Result. |
| mocks/database/orm/Query.go | Updated mock signatures and return types accordingly. |
| contracts/database/db/db.go | Updated interface definitions to use the new function parameters. |
| database/gorm/query.go | Changed underlying implementations to work with db.Result. |
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
database/db/query.go:252
- [nitpick] Consider updating the function comment to clearly explain the new parameters (x, y) and remove any outdated reference to a slice of arguments.
func (r *Query) OrWhereBetween(column string, x, y any) db.Query {
database/db/query.go:333
- Ensure that test cases adequately cover both update scenarios: one using a string as the column (with a single value) and the other using a map for multiple columns.
func (r *Query) Update(column any, value ...any) (*db.Result, error) {
contracts/database/orm/orm.go:56
- Confirm that the transition from orm.Result to db.Result is consistently applied across all interfaces and implementations to avoid type mismatches.
Delete(value ...any) (*db.Result, error)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #930 +/- ##
=======================================
Coverage 68.82% 68.82%
=======================================
Files 154 154
Lines 10200 10200
=======================================
Hits 7020 7020
Misses 2857 2857
Partials 323 323 ☔ View full report in Codecov by Sentry. |
almas-x
pushed a commit
that referenced
this pull request
Mar 12, 2025
almas-x
pushed a commit
that referenced
this pull request
Mar 18, 2025
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.
📑 Description
goravel/goravel#358
@coderabbitai summary
✅ Checks