node-orm2 icon indicating copy to clipboard operation
node-orm2 copied to clipboard

With association autoFetch cache may return incomplete instance.

Open stueynz opened this issue 10 years ago • 2 comments

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.

stueynz avatar Dec 09 '15 19:12 stueynz

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..

dxg avatar Dec 14 '15 01:12 dxg

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 avatar Dec 16 '15 22:12 stueynz