fix: increased test coverage and improved filter query perf - #40
Merged
Conversation
Reviewer's GuideThis PR refactors core query and projection logic for greater flexibility, optimizes filter query parsing for accurate type casting, cleans up legacy utility functions, and significantly expands test coverage across filtering, validation, transactions, scheduling, soft deletes, and read operations. Sequence Diagram for Updated filterquery.parseOperatorValue Type CastingsequenceDiagram
participant Caller
participant FQUtil as filterquery.util
participant CastLib as cast
participant MongoLib as primitive
Caller->>FQUtil: parseOperatorValue(value, operator)
FQUtil->>FQUtil: strVal = cast.ToString(value)
FQUtil->>FQUtil: strVal = replaceOperator(strVal, operator)
FQUtil->>CastLib: ToFloat64E(strVal)
alt CastLib returns float64_val (no error)
FQUtil-->>Caller: float64_val
else CastLib returns error
FQUtil->>MongoLib: ObjectIDFromHex(strVal)
alt MongoLib returns objectId_val (no error)
FQUtil-->>Caller: objectId_val
else MongoLib returns error
FQUtil->>CastLib: ToTimeE(strVal)
alt CastLib returns time_val (no error)
FQUtil-->>Caller: time_val
else CastLib returns error
FQUtil-->>Caller: strVal (as string)
end
end
end
Updated Class Diagram for Model[T]classDiagram
class Model~T~ {
+Select(fields ...any) Model~T~
+EnableSoftDelete() void
+DisableSoftDelete() void
+softDeletePayload() primitive.M
+UseCluster(connection *string) ClusterOp~T~
}
Class Diagram: Removed Functions from
|
| Change | Details | Files |
|---|---|---|
| Improved filter query parsing and type handling |
|
plugins/filterquery/util.goplugins/filterquery/filterquery.go |
| Refactor Model.Select to handle map, slice, and variadic inputs |
|
core/model.go |
| Adjust soft-delete methods to use pointer receivers |
|
core/model_query_delete.go |
| Clean up legacy utility functions |
|
utils/struct.goutils/slice.go |
| Reintroduce experimental UseCluster method |
|
core/cluster.go |
| Expand test coverage across modules |
|
tests/plugin_filter_query_test.gotests/plugin_sentinel_test.gotests/transaction_test.gotests/core_schedule_test.gotests/core_delete_test.gotests/core_read_ops_test.gotests/core_read_test.gotests/core_read_select_test.go |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Hey @Akalanka47000 - I've reviewed your changes - here's some feedback:
- The new parseOperatorValue drops boolean handling, so you should explicitly parse "true"/"false" into booleans instead of leaving them as strings.
- Your Select method assumes at least one argument, so add a guard for len(fields) == 0 to avoid a panic when no projection fields are passed.
- EnableSoftDelete and DisableSoftDelete now use pointer receivers but other mutating methods use value receivers—consider standardizing on pointer receivers for all stateful model methods to avoid unexpected behavior.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 by Sourcery
Optimize filter query parsing, extend filter syntax support, refactor core query and soft-delete APIs, remove obsolete utilities, and significantly expand test coverage across plugins, sentinel, transactions, scheduling, deletion, and read operations.
New Features:
Bug Fixes:
Enhancements:
Tests: