-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat: [#358] Implement LockForUpdate, SharedLock, Cursor, InRandomOrder methods #946
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## master #946 +/- ##
=======================================
Coverage 69.16% 69.16%
=======================================
Files 157 157
Lines 10519 10519
=======================================
Hits 7275 7275
Misses 2911 2911
Partials 333 333 β View full report in Codecov by Sentry. π New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR implements additional query methods including LockForUpdate, SharedLock, Cursor, and InRandomOrder while updating related interfaces, mock generators, and test cases to support these changes.
- Added new mock functions and interface methods for locking and cursor operations.
- Updated grammar interfaces and query implementations to integrate new Gorm clauses.
- Extended tests to cover the new query behaviours (locking and random ordering).
Reviewed Changes
File | Description |
---|---|
mocks/database/db/Row.go | Generated mocks for Row with unchanged Run/Return implementations. |
mocks/database/driver/DBGrammar.go | Added helper functions for compiling random order and locking clauses. |
database/gorm/row.go | Implements a new Row.Scan method based on mapstructure decoding. |
mocks/database/db/Query.go | Implements new mock functions for Cursor, InRandomOrder, LockForUpdate, SharedLock. |
database/db/query_test.go | Includes new tests for InRandomOrder, LockForUpdate, and SharedLock methods. |
database/db/query.go | Implements new query methods (Cursor, InRandomOrder, LockForUpdate, SharedLock) and reorders Limit method. |
contracts/database/db/db.go | Updates Query interface definitions to include new cursor and locking methods. |
mocks/database/driver/Driver.go | Adjusts the Gorm interface to match new method signature requirements. |
database/gorm/query.go | Updates Gorm query to switch from the legacy GormQuery to the new grammar approach. |
contracts/database/driver/grammar.go | Extends the Grammar interface with additional GormGrammar methods. |
Others (various mocks and conditions) | Updated for consistency with new flags and pointers in Conditions and grammar mocks. |
Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
database/gorm/query.go:161
- Currently, errors encountered during rows.MapScan are only logged via r.log.Errorf and then cause the goroutine to return without notifying the caller. Consider propagating these errors (for example, by sending a special error marker via a dedicated error channel or embedding error information in the Row type) to improve error transparency.
if err := rows.MapScan(row); err != nil {
π Description
goravel/goravel#358
β Checks