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

With association autoFetch cache may return incomplete instance. #685

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

stueynz
Copy link

@stueynz stueynz commented Dec 9, 2015

When cache has instance that has been loaded from auto-fetch, autoFetchLimit means can sometimes have instance in cache with no associations populated.

A subsequent independent get() or find() will return the underpopulated instance from the cache.

Updated the Singleton cache to check all autoFetch associations are populated before re-using object from cache.

@@ -112,6 +127,7 @@ function Model(opts) {
extend_associations : extend_associations,
association_properties : association_properties,
setupAssociations : setupAssociations,
checkAssociations : checkAssociations,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename this to hasAutoFetchAssociationsLoaded ?
It's a bit long, but more indicative of what it's actually doing.

@dxg
Copy link
Collaborator

dxg commented Dec 14, 2015

How does this behave when someone manually specifies authFetch: false when getting a model (given that autoFetch is set to true in the definition) ?

Also could you please convert spaces to tabs? It will help with alignment issues.
I'm tempted to switch the whole projects from tabs -> spaces as it's a constant source of problems, but haven't done it yet..

@stueynz
Copy link
Author

stueynz commented Dec 16, 2015

re: using autoFetch manually, something's not exactly intuitive. AutoFetch will take place if either of the autoFetch settings is true.

Maybe setting autoFetch to false manually should override the true setting in the model definition.

stueynz and others added 6 commits December 17, 2015 18:17
…utoFetch' setting from the association definition.
…ton for the associative entity needs to include both keys to be sure we get the right set of extra data
Extend UID for Singleton when hasMany relationship has extra data
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.

None yet

2 participants