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: [#614] Optimize facades.Orm().Query().Exists(), Order() and Count() methods #929

Merged
merged 4 commits into from
Mar 3, 2025

Conversation

hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Mar 2, 2025

πŸ“‘ Description

Closes goravel/goravel#614

@coderabbitai summary

βœ… Checks

  • Added test cases for my code

@Copilot Copilot bot review requested due to automatic review settings March 2, 2025 02:48
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 2, 2025 02:48
Copy link

@Copilot Copilot AI left a 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 optimizes the Query.Exists() method by changing its signature to return a (bool, error) pair rather than taking a pointer argument. Key changes include updating the mocks to align with the new signature, modifying the actual Query.Exists implementation in the database package, and updating tests and contracts to reflect the new behavior.

Reviewed Changes

File Description
mocks/database/orm/Query.go Updated mock function for Exists to match the new (bool, error) API.
database/gorm/query.go Adjusted the Exists implementation to return a bool and error.
tests/query_test.go Modified tests to work with the revised Exists signature.
contracts/database/orm/orm.go Updated the interface for Exists to match the new signature.

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 76e4256 Previous: 84fded1 Ratio
BenchmarkFile_ReadWrite 298600 ns/op 2072 B/op 28 allocs/op 184761 ns/op 2072 B/op 28 allocs/op 1.62
BenchmarkFile_ReadWrite - ns/op 298600 ns/op 184761 ns/op 1.62

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Mar 2, 2025

Codecov Report

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

Project coverage is 68.82%. Comparing base (84fded1) to head (d227ee4).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #929   +/-   ##
=======================================
  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.
πŸ“’ Have feedback on the report? Share it here.

@hwbrzzl hwbrzzl changed the title feat: [#614] Optimize facades.Orm().Query().Exists() method feat: [#614] Optimize facades.Orm().Query().Exists(), Order() and Count() methods Mar 2, 2025
@@ -107,11 +107,14 @@ type Query interface {
// Omit specifies columns that should be omitted from the query.
Omit(columns ...string) Query
// Order specifies the order in which the results should be returned.
// DEPRECATED Use OrderByRaw instead.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with Laravel

@hwbrzzl hwbrzzl merged commit c3e937f into master Mar 3, 2025
14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#614 branch March 3, 2025 03:43
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.

Optimize facades.Orm().Query().Exists(), Order() and Count() methods
1 participant