Skip to content

feat: [#358] Add Count, Pluck, DoesntExist, Distinct, FirstOr, Decrement, Increment, InsertGetId, When methods - #931

Merged
hwbrzzl merged 20 commits into
masterfrom
bowen/#358-11
Mar 3, 2025
Merged

feat: [#358] Add Count, Pluck, DoesntExist, Distinct, FirstOr, Decrement, Increment, InsertGetId, When methods#931
hwbrzzl merged 20 commits into
masterfrom
bowen/#358-11

Conversation

@hwbrzzl

@hwbrzzl hwbrzzl commented Mar 2, 2025

Copy link
Copy Markdown
Contributor

📑 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
@codecov

codecov Bot commented Mar 2, 2025

Copy link
Copy Markdown

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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
@hwbrzzl
hwbrzzl deleted the bowen/#358-11 branch March 3, 2025 14:35
almas-x pushed a commit that referenced this pull request Mar 12, 2025
…ent, Increment, InsertGetId, When methods (#931)

* feat: [#358] Add Value method

* chore: update mocks

* Add Limit method

* update mock

* fix sqlserver limit

* chore: update mocks

* remove unnecessary code

* add Count method

* chore: update mocks

* add FirstOr method

* add FirstOr method

* add DoesntExist method

* add InsertGetId method

* add Latest method

* add Latest method

* add Distinct method

* update mock

* update mock

* cancel test

* optimize Pluck

---------

Co-authored-by: hwbrzzl <24771476+hwbrzzl@users.noreply.github.com>
almas-x pushed a commit that referenced this pull request Mar 18, 2025
…ent, Increment, InsertGetId, When methods (#931)

* feat: [#358] Add Value method

* chore: update mocks

* Add Limit method

* update mock

* fix sqlserver limit

* chore: update mocks

* remove unnecessary code

* add Count method

* chore: update mocks

* add FirstOr method

* add FirstOr method

* add DoesntExist method

* add InsertGetId method

* add Latest method

* add Latest method

* add Distinct method

* update mock

* update mock

* cancel test

* optimize Pluck

---------

Co-authored-by: hwbrzzl <24771476+hwbrzzl@users.noreply.github.com>
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.

2 participants