David Rogers
05/11/2023, 6:47 PMDavid Rogers
05/11/2023, 6:50 PMelpete
05/11/2023, 6:53 PMNO_GLOBAL_SCOPES
?
Is it on qCompetitionRegistration
?David Rogers
05/11/2023, 6:53 PMDavid Rogers
05/11/2023, 6:55 PMscope*
methods now?Ryan Albrecht
05/11/2023, 7:02 PMDavid Rogers
05/11/2023, 7:03 PMfunction NO_GLOBAL_SCOPES() {...}
.Ryan Albrecht
05/11/2023, 7:05 PMRyan Albrecht
05/11/2023, 7:05 PMDavid Rogers
05/11/2023, 7:05 PMRyan Albrecht
05/11/2023, 7:08 PMDavid Rogers
05/11/2023, 7:12 PMcomponent X {
function Y() { return hasOne(Y) }
}
component Y {
function FOO() { ... }
}
// later
getInstance("X").firstOrFail().Y().FOO() // Method FOO does not exist on QueryBuilder (thrown a little deeper but QuickBuilder:627 kicks it off)
Ryan Albrecht
05/11/2023, 7:17 PM.Y()
returns the relationship instance whereas, .getY()
would return the entity instance. Somehow in quick 5 that method used to be forwarded onto the entity somehow but now it is not.David Rogers
05/11/2023, 7:18 PMelpete
05/11/2023, 7:26 PM.Y()
above returns a Relationship which in turn has a QuickBuilder associated with it. The only methods that will be looked up on the associated entity are scopes, methods that start with scope***
.
Now, I believe you are coming from v4. In v4 it worked because the entity held on to the builder. In v5 the builder was decoupled for performance reasons. At that point the long standing idea of only scopes being callable from a builder was enforced. It has always been the position of the docs that scopes are the only functions on an entity that can be called from builders.
Does that help clear things up?David Rogers
05/11/2023, 7:28 PMelpete
05/11/2023, 7:30 PMRyan Albrecht
05/11/2023, 7:31 PMelpete
05/11/2023, 7:31 PMget{relationshipName}
you would have either an entity or array of entities and the method would work just like any other method.David Rogers
05/11/2023, 7:32 PMY
not getY
), and I want to configure the builder, to not use any global scopes, so probably, haha, function scopeNoGlobalScope()
is the new hotnesselpete
05/11/2023, 7:33 PMwithoutGlobalScopes
method that @Ryan Albrecht mentioned would be an option as well.David Rogers
05/11/2023, 7:34 PMRyan Albrecht
05/11/2023, 7:35 PMgetInstance("X").firstOrFail().Y().withoutGlobalScopes([names]).get()
David Rogers
05/11/2023, 7:35 PMRyan Albrecht
05/11/2023, 7:36 PMelpete
05/11/2023, 7:45 PMelpete
05/11/2023, 7:46 PMDavid Rogers
05/11/2023, 7:55 PMfunction applyGlobalScopes( qb ) {
if (this.NO_GLOBAL_SCOPES_ ?: false) {
return
}
qb.addABunchOfSubselects1()
qb.addABunchOfSubselects2()
...
}
function NO_GLOBAL_SCOPES() { this.NO_GLOBAL_SCOPES_ = true; return this; }
roughly ~10 probablyDavid Rogers
05/11/2023, 7:58 PMthis
and get the same this
in applyGlobalScopes?
function scopeNoGlobalScopes() { this.NO_GLOBAL_SCOPES_ = true; }
Ryan Albrecht
05/11/2023, 7:58 PM_globalScopeExcludeAll
which is defaulted to false. The withoutGlobalScope
method now has an optional parameter. If no parameter is passed in then set this private variable to true. Do a check on ``_globalScopeExcludeAll` ` before applying global scopes. Check line 1027 and line 1047 in the below imageRyan Albrecht
05/11/2023, 8:00 PMelpete
05/11/2023, 8:28 PMRyan Albrecht
05/11/2023, 9:56 PMRyan Albrecht
05/11/2023, 9:58 PMRyan Albrecht
05/11/2023, 9:58 PMelpete
05/11/2023, 10:48 PMRyan Albrecht
05/11/2023, 11:07 PMRyan Albrecht
05/12/2023, 3:00 PM