-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Should global scopes of pivot model be applied? #261
Comments
Seems like a bug by looking at first glance, lemme get into it in more depth later |
@radmen Mind testing same by installing lucid from Github? |
@thetutlage is this update released on NPM? I've checked version |
Nope, that's why I said try it from Github |
Ah, sorry. Will check it now. |
Fix still fails in my project. Later (hopefully in next days) I'll prepare a clean Adonis installation and will try to reproduce it here. |
@thetutlage I've prepared an example app which allows to reproduce the problem: https://github.com/radmen/adonis-lucid-pivot-global-scopes |
Looked at the repo, the global scope should be added to the |
I might be misunderstanding something. |
Yes I believe the relationship should apply scopes from the pivot model when defined. Thinking of other relations too 🤔 |
Here's quite interesting case.
First I'll try to give valid example code (based on docs):
App/Models/User
App/Models/OwnerCar
Attaching car to user (using
ownedCars()
) will set properlyis_current_owner
flag.After few hours of hard debugging I've found out that global scope is applied when using
attach()
,detach()
yet it's not the case when I'm trying to use egfetch()
orcount()
. Same goes for eager loads (with('ownedCars')
orload('ownedCars')
)I've dwelled into the code and it looks that global scope is not applied to data which is loaded eagerly.
Should global scope be applied when fetching data?
One thing I from the code I can tell is that it won't be that easy to implement.
The text was updated successfully, but these errors were encountered: