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

feat: [#358] Implement LockForUpdate, SharedLock, Cursor, InRandomOrder methods #946

Merged
merged 8 commits into from
Mar 8, 2025

Conversation

hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Mar 7, 2025

πŸ“‘ Description

goravel/goravel#358

βœ… Checks

  • Added test cases for my code

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 69.16%. Comparing base (f991a2d) to head (f7d33dd).
Report is 1 commits behind head on master.

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.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl changed the title feat: [#358] Implement LockForUpdate method feat: [#358] Implement LockForUpdate, SharedLock, Cursor methods Mar 8, 2025
@hwbrzzl hwbrzzl changed the title feat: [#358] Implement LockForUpdate, SharedLock, Cursor methods feat: [#358] Implement LockForUpdate, SharedLock, Cursor, InRandomOrder methods Mar 8, 2025
@hwbrzzl hwbrzzl marked this pull request as ready for review March 8, 2025 10:03
@Copilot Copilot bot review requested due to automatic review settings March 8, 2025 10:03
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 8, 2025 10:03

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 {
@hwbrzzl hwbrzzl merged commit cabc06d into master Mar 8, 2025
11 of 13 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#358-17 branch March 8, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant