orm icon indicating copy to clipboard operation
orm copied to clipboard

🐛 Self transation cannot be resolved.

Open peldax opened this issue 8 months ago • 4 comments

No duplicates 🥲.

  • [X] I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Hi,

I am getting a following error when persisting a self referencing entitiy, such as following:

#[Entity(database: 'main')]
class Catalogue
{
    #[Column(type: 'primary')]
    private int $id;

    #[RefersTo(target: self::class, nullable: true)]
    private ?self $catalogue = null;

    #[HasMany(target: self::class)]
    private array $catalogues = [];
}

Error message:

Cycle\ORM\Exception\TransactionException: Transaction can't be finished. Some relations can't be resolved:
Create new `catalogue`
 - catalogue.catalogues:catalogue (Cycle\ORM\Relation\ShadowBelongsTo)

It seems that the ORM is having trouble understanding the selfReferencing relation.

Version

- ORM 2.8
- PHP 8.3.7

peldax avatar Jun 23 '24 16:06 peldax