Skip to content

feat: [#646] The Where function of Orm supports func condition#975

Merged
almas-x merged 1 commit intomasterfrom
almas/#646
Mar 28, 2025
Merged

feat: [#646] The Where function of Orm supports func condition#975
almas-x merged 1 commit intomasterfrom
almas/#646

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented Mar 27, 2025

📑 Description

Closes goravel/goravel#646

facades.Orm().Query().Where(func(query orm.Query) orm.Query {
		return query.Where("name != ?", "admin")
	}).FindOrFail(&user, 100)

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings March 27, 2025 10:14
@almas-x almas-x requested a review from a team as a code owner March 27, 2025 10:14
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.

Pull Request Overview

This PR adds support for function-based conditions in the Orm Where method and updates the tests to verify this new functionality.

  • Introduce a new branch in the Query.Where method for functional conditions.
  • Add a new test case to verify that the functional condition is applied correctly.

Reviewed Changes

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

File Description
tests/query_test.go Adds a test case for functional conditions but appears to check the wrong user variable.
database/gorm/query.go Implements support for functional condition in the Where method.

@codecov
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.25%. Comparing base (14d38dd) to head (616cd16).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #975   +/-   ##
=======================================
  Coverage   69.25%   69.25%           
=======================================
  Files         160      160           
  Lines       10712    10712           
=======================================
  Hits         7419     7419           
  Misses       2958     2958           
  Partials      335      335           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Nice 👍

@almas-x almas-x merged commit 12808d1 into master Mar 28, 2025
13 checks passed
@almas-x almas-x deleted the almas/#646 branch March 28, 2025 01:50
almas-x added a commit that referenced this pull request Apr 2, 2025
almas-x added a commit that referenced this pull request Apr 2, 2025
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.

The Where function of Orm supports func condition

4 participants