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

fix: Fix all scopes #493

Merged
merged 2 commits into from
May 30, 2024
Merged

fix: Fix all scopes #493

merged 2 commits into from
May 30, 2024

Conversation

ahmed3mar
Copy link
Contributor

Closes #

📑 Description

The problem with the initial implementation of the buildScopes method in the QueryImpl struct is that it incorrectly captures the loop variable scope when appending to the gormFuncs slice. This results in all functions in the gormFuncs slice referring to the last scope value in the loop, causing only the last scope to be executed correctly.

This issue arises because the loop variable scope is captured by reference in the anonymous function. When the loop finishes, all the anonymous functions hold a reference to the last value of scope, leading to incorrect behavior.

The solution involves capturing the current value of scope inside the loop by introducing a new variable to hold the current scope. This ensures that each function in the gormFuncs slice captures its own distinct value of scope.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

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

@hwbrzzl
Copy link
Contributor

hwbrzzl commented May 29, 2024

Thanks @ahmed3mar please rebase your branch, will approve again.

Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.03%. Comparing base (8b03f9c) to head (2770164).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #493   +/-   ##
=======================================
  Coverage   70.03%   70.03%           
=======================================
  Files         176      176           
  Lines       10849    10850    +1     
=======================================
+ Hits         7598     7599    +1     
  Misses       2683     2683           
  Partials      568      568           

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

@hwbrzzl hwbrzzl merged commit 6a39d0e into goravel:master May 30, 2024
8 checks passed
kkumar-gcc added a commit that referenced this pull request Sep 13, 2024
kkumar-gcc added a commit that referenced this pull request Sep 14, 2024
kkumar-gcc added a commit that referenced this pull request Sep 15, 2024
kkumar-gcc added a commit that referenced this pull request Sep 16, 2024
* optimize session

* optimize session module

* optimize session module

* chore: update mocks

* remove unused method

* fix ReleaseSession

* update manager tests

* chore: update mocks

* update test cases for session

* fix:lint

* fix:lint

* remove redundant error

---------

Co-authored-by: kkumar-gcc <kkumar-gcc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants