You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discrepancy (title) creates a scenario where if you have an implementation that relies on EagerLoading and LazyLoading you will get a different interaction. Lets take the following example:
ActiveForce::ActiveQuery implements it's own version of .select that does not work with an array's version of select. Hence we get an SOQL error.
Desired interaction
There should be no change in interaction if we lazyload or eagerload associations because sometimes we need to allow for both.
Current interaction
We can get around this issue by translating every relation into an Array before calling methods like .select on it.
account.partner_opportunities.to_a.select { |partner_opportunity| partner_opportunity.type == 'Some Random Type' }
This creates a confusing dev experience that is prone to errors when working with both lazy and eagerloaded objects.
Desired solution
In ActiveRecord they have a new object called ActiveRecord::Collection that would be returned in these scenarios. Something like this would be a better experience.
The text was updated successfully, but these errors were encountered:
bfrey08
changed the title
[BUG] When an ActiveForce object's association is eagerloaded it is an Array. When it is lazy loaded, it is ActiveForce::ActiveQuery
[FEATURE] When an ActiveForce object's association is eagerloaded it is an Array. When it is lazy loaded, it is ActiveForce::ActiveQueryMar 8, 2024
bfrey08
changed the title
[FEATURE] When an ActiveForce object's association is eagerloaded it is an Array. When it is lazy loaded, it is ActiveForce::ActiveQuery
[Bug] When an ActiveForce object's association is eagerloaded it is an Array. When it is lazy loaded, it is ActiveForce::ActiveQueryMar 8, 2024
bfrey08
changed the title
[Bug] When an ActiveForce object's association is eagerloaded it is an Array. When it is lazy loaded, it is ActiveForce::ActiveQuery
[Feature] When an ActiveForce object's association is eagerloaded it is an Array. When it is lazy loaded, it is ActiveForce::ActiveQueryMar 8, 2024
Describe the issue
This discrepancy (title) creates a scenario where if you have an implementation that relies on EagerLoading and LazyLoading you will get a different interaction. Lets take the following example:
What does this solve?
and call
You will get
When you want to filter (in memory) the partner_opportunities, you will do something like this:
Now lets say we use the same code in a different area of the APP except we want to lazyload instead of eagerlaod:
now lets try and filter this account:
ActiveForce::ActiveQuery implements it's own version of .select that does not work with an array's version of select. Hence we get an SOQL error.
Desired interaction
There should be no change in interaction if we lazyload or eagerload associations because sometimes we need to allow for both.
Current interaction
We can get around this issue by translating every relation into an Array before calling methods like .select on it.
This creates a confusing dev experience that is prone to errors when working with both lazy and eagerloaded objects.
Desired solution
In ActiveRecord they have a new object called ActiveRecord::Collection that would be returned in these scenarios. Something like this would be a better experience.
The text was updated successfully, but these errors were encountered: