coldbox-modules / quick

A ColdBox ORM Engine
https://quick.ortusbooks.com
MIT License
23 stars 19 forks source link

.retrieveQuery() called on a relationship does not invoke global scopes #221

Closed MordantWastrel closed 1 year ago

MordantWastrel commented 1 year ago

Given entity user with many posts:

someUser.posts.get() will return the user's posts, with the global scopes correctly invoked.

someUser.posts().retrieveQuery().get() will not invoke the global scopes on the query.

someUser.posts().withSomeScope().retrieveQuery().get() works, so you can work around the issue by just manually invoking all the scopes you want, but code relying on relationship's global scopes being applied in a drop-to-qb situation will break with v6.

elpete commented 1 year ago

The solution being pursued here is to use asQuery instead of retrieveQuery. Further issues arising from that are logged in subsequent tickets.