I am trying to build an ethnicity categorization hierarchy, and I have encountered some behaviour I don’t understand.
I have used the tree behaviour to build a table for ethnicities, and it seems to be working well. However, when I define the eager loading of data using the ‘contain’ functionality in my controller, any child nodes that themselves have child nodes are omitted from the found set under some circumstances.
When I eager load only children, like so:
$ethnicity = $this->Ethnicities->get($id, [ 'contain' => [ 'ParentEthnicities.ParentEthnicities', 'ChildEthnicities', 'Students' ], ]);
All nodes are loaded correctly.
However, when I try to eager load children of children, like this:
$ethnicity = $this->Ethnicities->get($id, [ 'contain' => [ 'ParentEthnicities.ParentEthnicities', 'ChildEthnicities.ChildEthnicities', 'Students' ], ]);
Any nodes which have children themselves are omitted.
Is there something I am missing?