Skip to content

Cannot load related entities through many to many relations via LEFT_JOIN #71

Description

@mrakolice

$select->load('many_to_many.has_many') failed with Undefined node 'has_many' exception.

$select->load('many_to_many.@.has_many') failed with Undefined relation 'pivotTestModel'.'has_many' exception.

This problem in AbstractLoader#251 in $node->getNode($relation) function.

In debug $node has this structure:

image

Here my models

/**
 * @Entity
 */
class ManyToManyTestModel extends BaseTestModel
{
    public function __construct(array $data = [])
    {
        $this->many_to_many_inverse = new PivotedCollection();
        $this->has_many = new ArrayCollection();
        parent::__construct($data);
    }

    /**
     * @ManyToMany(though=PivotTestModel::class, target=HasManyTestModel::class)
     */
    public $many_to_many_inverse;

    /** @HasMany(target=RelatedModel::class, nullable=true) */
    public $has_many;
}

/**
 * @Entity
 */
class HasManyTestModel extends BaseTestModel
{
    public function __construct(array $data = [])
    {
        $this->many_to_many = new PivotedCollection();

        parent::__construct($data);
    }

    /**
     * @ManyToMany(target=ManyToManyTestModel::class, though=PivotTestModel::class)
     */
    public $many_to_many;

    public $has_many_inverse;
}

/**
 * @Entity
 */
class PivotTestModel
{
    /**  @Column(type="primary") */
    public $id;
}

/**
 * @Entity
 */
class RelatedModel extends BaseTestModel
{
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionFurther information is requested

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions