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] Add Count, Pluck, DoesntExist, Distinct, FirstOr, Decrement, Increment, InsertGetId, When methods #931

Merged
merged 20 commits into from
Mar 3, 2025

Conversation

hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Mar 2, 2025

📑 Description

goravel/goravel#358

@coderabbitai summary

✅ Checks

  • Added test cases for my code

@hwbrzzl hwbrzzl changed the title feat: [#358] Add Value method feat: [#358] Add Limit, Value, Pluck method Mar 2, 2025
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 (c3e937f) to head (791bda4).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #931   +/-   ##
=======================================
  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.

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: 50f17a6 Previous: c3e937f Ratio
BenchmarkFile_ReadWrite 296340 ns/op 2072 B/op 28 allocs/op 188515 ns/op 2072 B/op 28 allocs/op 1.57
BenchmarkFile_ReadWrite - ns/op 296340 ns/op 188515 ns/op 1.57

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

@hwbrzzl hwbrzzl changed the title feat: [#358] Add Limit, Value, Pluck method feat: [#358] Add Count, Pluck, DoesntExist, Distinct, FirstOr, Decrement, Increment, InsertGetId, When methods Mar 3, 2025
@hwbrzzl hwbrzzl marked this pull request as ready for review March 3, 2025 13:28
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 3, 2025 13:28
@hwbrzzl hwbrzzl requested a review from Copilot March 3, 2025 14:29

Choose a reason for hiding this comment

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

PR Overview

This PR introduces new query methods—including Count, Pluck, DoesntExist, FirstOr, Decrement, Increment, InsertGetId, When, and Latest—to enhance the database query builder functionality and adds corresponding tests for these methods.

  • New query methods in database/db/query.go with updated condition field naming.
  • Updated test files (database/db/query_test.go and tests/db_test.go) to cover the added methods.
  • Adjustments to the mock builder and interface contracts to support the new functionality.

Reviewed Changes

File Description
database/db/query_test.go Added tests for Count, Decrement, Distinct, FirstOr, Increment, InsertGetId, Latest, When, and Pluck.
tests/db_test.go Extended tests for query methods including Count, Decrement, Distinct, Increment, InsertGetId, and Pluck.
mocks/database/db/Builder.go Added Query method mocks to support new builder functionality.
database/db/query.go Introduced new query methods and updated condition field references to uppercase.
contracts/database/db/db.go Updated the Query interface with new methods and detailed comments.
database/db/conditions.go Updated Conditions struct field names from lowercase to uppercase.
database/db/utils.go Modified error returns in the conversion functions to use a standardized error message.

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

database/db/query.go:68

  • [nitpick] In the Count() method, the trace() call uses -1 for rowsAffected even on success; consider using a more representative value (e.g., the actual count) or a consistent placeholder to improve logging clarity.
r.trace(sql, args, -1, nil)
@hwbrzzl hwbrzzl merged commit 279fdf5 into master Mar 3, 2025
14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#358-11 branch March 3, 2025 14:35
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