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

[Bug]: Columns declared in non-entity classes are ignored 🐛 #101

Open
1 task done
peldax opened this issue Jun 21, 2024 · 0 comments
Open
1 task done

[Bug]: Columns declared in non-entity classes are ignored 🐛 #101

peldax opened this issue Jun 21, 2024 · 0 comments
Assignees
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@peldax
Copy link

peldax commented Jun 21, 2024

No duplicates 🥲.

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

What happened?

Hi,

In a scenario where some sort of BaseEntity is used to contain Columns appearing across multiple Entitys, those columns are not registered into the Entitys extending this base class.

abstract class EmployedPerson
{
    #[Column(type: 'integer')]
    protected int $id;
}

#[Entity]
class Developer extends EmployedPerson {
    #[Column(type: 'integer')]
    protected int $salary;
}

In the example above, the id column is not added to the Developer entity.

This is probably caused by Configurator:115:

$field->setEntityClass($property->getDeclaringClass()->getName());

where the field is set to entity by a declaring class, but this class is not an entity.

This should work also in combination with JTI, where a following hierarchy could be used:

#[Entity]
class Person {
    #[Column(type: 'primary')]
    protected int $id;
}

abstract class EmployedPerson extends Person
{
    #[Column(type: 'integer')]
    protected int $salary;
}

#[Entity]
#[JoinedTable]
class Developer extends EmployedPerson {
    #[Column(type: 'integer')]
    protected int $foo;
}

In the example above, the Developer table should contain columns id, salary and foo, but currently the salary is ignored.

Version

  • OS: PopOS
  • PHP version: 8.3.7
  • Package version:
    • annotated: 4.1
    • database: 2.11
    • orm: 2.8
    • schema-builder: 2.8

ORM Schema

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
Status: Todo
Development

No branches or pull requests

2 participants