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
I'm having some problems with objects when the relations form a graph.
Consider this:
Factory.define "author", Author, { name: "F. Scott Fitzgerald" }
Factory.define "book", Book, { title: "The Great Gatsby": author: Factory.get("author") }
Factory.define "contract", Contract, { author: Factory.get("author"), book: Factory.get("book") }
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: