Skip to content

feat: [#358] Optimize the difference between db and orm#930

Merged
hwbrzzl merged 1 commit intomasterfrom
bowen/#358-10
Mar 2, 2025
Merged

feat: [#358] Optimize the difference between db and orm#930
hwbrzzl merged 1 commit intomasterfrom
bowen/#358-10

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Mar 2, 2025

📑 Description

goravel/goravel#358

@coderabbitai summary

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings March 2, 2025 04:43
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 2, 2025 04:43
Copy link
Contributor

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 differences between the database and ORM layers by updating function signatures and return types to use the new db interfaces consistently. Key changes include:

  • Changing the function signatures of OrWhereBetween and OrWhereNotBetween from using a slice of values to explicitly passing two arguments (x and y).
  • Updating the Update and Delete methods (and their mocks) to return *db.Result instead of *orm.Result.
  • Adjusting interface definitions in contracts and mocks to reflect the new types and parameters.

Reviewed Changes

File Description
database/db/query_test.go Updated tests to invoke Between methods with explicit x, y arguments.
database/db/query.go Modified OrWhereBetween, OrWhereNotBetween, and Update signatures.
mocks/database/db/Query.go Adjusted mock implementations to match new function signatures.
contracts/database/orm/orm.go Updated method return types from orm.Result to db.Result.
mocks/database/orm/Query.go Updated mock signatures and return types accordingly.
contracts/database/db/db.go Updated interface definitions to use the new function parameters.
database/gorm/query.go Changed underlying implementations to work with db.Result.

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

Comments suppressed due to low confidence (3)

database/db/query.go:252

  • [nitpick] Consider updating the function comment to clearly explain the new parameters (x, y) and remove any outdated reference to a slice of arguments.
func (r *Query) OrWhereBetween(column string, x, y any) db.Query {

database/db/query.go:333

  • Ensure that test cases adequately cover both update scenarios: one using a string as the column (with a single value) and the other using a map for multiple columns.
func (r *Query) Update(column any, value ...any) (*db.Result, error) {

contracts/database/orm/orm.go:56

  • Confirm that the transition from orm.Result to db.Result is consistently applied across all interfaces and implementations to avoid type mismatches.
Delete(value ...any) (*db.Result, error)

@codecov
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 (61702e0) to head (a051794).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #930   +/-   ##
=======================================
  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 merged commit 62ae533 into master Mar 2, 2025
14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#358-10 branch March 2, 2025 04:49
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