Open mlanett opened 9 years ago
Also one may have a graph after calling multiple create methods, so exposing the cache optionally may also make sense.
Hey @mlanett seems like a valid point, I wonder if such a feature has been implemented in similar packages?
I'm having some problems with objects when the relations form a graph.
Consider this:
When we Factory.create("contract"), we fail because there will be two inserts of author; one by contract and one when it creates the relation for book. We should only have one author object and the same id in both places. This can be fixed by after() hooks but it's a mess.
But, for this following case we might expect that a relation is different each time.
It's easy to fix the first case by putting a name:object cache in Factory.build and using it to ensure that relations created unique objects. But that would break the latter case. Is the latter case a reasonable expectation? If not then I can probably build the cache and make a PR. If so then we need to figure out the best way to accommodate it.