-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Description
Description
Hello
In some case $aTable->loadInto( $this, [ 'bTable.cTable' ] );
failed with error "The includeFields
association is not defined on UserGroups
. Valid associations are: Parent, SiblingChildren".
Sorry, I've no simple TestCase/UnitTest :(
But if I comment $config['includeFields'] = true;
in Cake\ORM\LazyEagerLoader::_getQuery()
in attachableAssociations() loop
every things work without error.
// vendor/cakephp/cakephp/src/ORM/LazyEagerLoader.php
namespace Cake\ORM;
class LazyEagerLoader
{
...
protected function _getQuery(CollectionInterface $objects, array $contain, Table $source): Query
{
...
foreach ($query->getEagerLoader()->attachableAssociations($source) as $loadable) {
$config = $loadable->getConfig();
// $config['includeFields'] = true; <- COMMENT HERE
$loadable->setConfig($config);
}
return $query;
}
Effectively if not commented, the EagerLoader::_normalizeContain()
try to addAssociation( "includeFields" )
which is a forced configuration not a table :-(
// vendor/cakephp/cakephp/src/ORM/EagerLoader.php
namespace Cake\ORM;
class EagerLoader
{
...
protected function _normalizeContain(Table $parent, string $alias, array $options, array $paths): EagerLoadable
{
...
foreach ($extra as $t => $assoc) {
Log::debug(__METHOD__.' $t: '.$t); // <-- Here $t == "includeFields" ;
$eagerLoadable->addAssociation( $t, $this->_normalizeContain($table, $t, $assoc, $paths)
);
}
return $eagerLoadable;
}
CakePHP Version
4.3.1
PHP Version
7.4