Open bostondv opened 7 years ago
Hello @bostondv, thank you for opening this issue. My first guess is that the through table hasn't been generated at the point when the fixtures are loaded. I guess you are defining this relationship programmatically? If so, you could try defining the AssemblyPart model explicitly, this should fix this issue. Please let me know if this helps or not.
Hey @JonathanPrince, that's correct. I was using hasAndBelongsToMany
relations which automatically generates the through model. Eg:
"relations": {
"parts": {
"type": "hasAndBelongsToMany",
"model": "Part",
}
}
I tried your suggestion and explicitly defined the through model with a hasMany
relation on the Assembly
and Part
models and the setup worked without any problems.
Do you think it'd be possible to support the generated relations in the future though?
Hi @bostondv, sorry it's taken a while to get back to you. Perhaps this could be added as an extra config option to check each model for any through tables that are not explicitly defined and create them as needed. It's not a priority for me at this stage, if you're keen PR's are always welcome.
Fixture setup fails when trying to populate the auto-generated intervening model between two models with hasAndBelongsToMany relation.
Based on this example using an
AssemblyPart.json
fixture will fail on setup.AssemblyPart.json:
Is this a bug / missing feature or am I doing something wrong?
Thanks!