dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

With association autoFetch cache may return incomplete instance. #685

Open stueynz opened 8 years ago

stueynz commented 8 years ago

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.

dxg commented 8 years ago

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 commented 8 years ago

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.