Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple inheritance mapped superclasses in different namespaces #11488

Open
cyrilverloop opened this issue Jun 3, 2024 · 0 comments
Open

Multiple inheritance mapped superclasses in different namespaces #11488

cyrilverloop opened this issue Jun 3, 2024 · 0 comments

Comments

@cyrilverloop
Copy link

cyrilverloop commented Jun 3, 2024

Bug Report

Q A
BC Break yes/no
Version 2.19 => 3.2

Summary

Hi,

On a Symfony 7 app, you can not have multiple inheritance mapped superclasses in different namespaces.

May be related to : #11404

Current behavior

Generating the migrations with ./bin/console make:migration gives the error : Duplicate definition of column 'id' on entity 'App\Entity\Daughter' in a field or discriminator column mapping.

How to reproduce

<?php

declare(strict_types=1);

namespace App\SomewhereElse;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\MappedSuperclass()]
abstract class BaseEntity
{
    #[
        ORM\Id(),
        ORM\Column(type: Types::INTEGER),
        ORM\GeneratedValue(strategy: "AUTO")
    ]
    protected ?int $id;
}
<?php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\MappedSuperclass()]
abstract class BaseEntity
{
    #[
        ORM\Id(),
        ORM\Column(type: Types::INTEGER),
        ORM\GeneratedValue(strategy: "AUTO")
    ]
    protected ?int $id;
}
<?php

declare(strict_types=1);

namespace App\Entity;

use App\SomewhereElse\BaseEntity; // Comment this line to make the problem disappear.
use Doctrine\ORM\Mapping as ORM;

#[ORM\MappedSuperclass()]
abstract class Mother extends BaseEntity {}
<?php

declare(strict_types=1);

namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
class Daughter extends Mother {}

If App\Entity\Mother extends App\SomewhereElse\BaseEntity, the error appears (report_fields_where_declared: true with ORM 2.x).
If App\Entity\Mother extends App\Entity\BaseEntity, it works.

Expected behavior

I would like to be able to extend mapped superclasses from libraries (other namespaces).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant