Open peldax opened 2 weeks ago
Hello. Good catch. Looks like a bug.
Hi @roxblnfk ,
I tried to dig into the internals but the learning curse seems very steep, as I am not very familiar with the whole system. Would you give me some pointers where to look in order for me to provide a fix? Or is there something else I can do to accelerate the resolution? I am also open to bounty this bug if you had spare time to prioritize things.
Thanks, VP
It's nice to hear that.
Perhaps the fixes will be in schema-builder
, but I think it's worth starting with tests in the annotated
package.
I tried to work around the issue using JTI and I possibly found another bug, which may be related.
#[Entity(database: 'main')]
class Question
{
#[Column(type: 'primary')]
protected int $id;
#[BelongsTo(target: OtherEntity::class)]
protected OtherEntity $otherEntity;
}
#[Entity(database: 'main')]
#[JoinedTable]
class QuestionChoice extends Question
{
}
#[Entity(database: 'main')]
#[JoinedTable]
class QuestionTextual extends Question
{
}
#[Entity(database: 'main')]
#[JoinedTable]
class QuestionMultichoice extends Question
{
}
By using this attribute setup, all the belongsTo
/refersTo
relation columns from parent entity (in this case the OtherEntity
relation) are added to the parent questions
table and also to the all joined tables as well. In my opinion the column should be added only to the parent table.
In my opinion the column should be added only to the parent table
That's true
Describe the bug
Hi, I am trying to integrate CycleORM into a Symfony application, in order to replace Doctrine, and I encountered a strange behavior with relations.
I will show you the example first.
I trimmed all the other tables and managed to reproduce on following 4 entities:
Those entities result in following database schema:
The strange thing this issue is about is the nullability of
questionChoice_id
column. For some reason the column is declared as NOT NULL, while others are nullable - and all the columns have identical attribute declaration.In this usecase the question has 3 possible types and the tables include some additional settings. In the base table the relation is nullable, because only one of the 3 columns is filled. However in the extending tables the column is not null, because it must have a base table paired to it.
There might be some sort of misunderstanding of the CycleORM relations on my side, but it seems strange to me that one column has different nullability than the others. When the
HasOne
attribute is removed from the entitiy, the nullability is corrected.Is this a regression?
I cannot tell as I am a new user of Cycle ORM.
To Reproduce
Use the default setup and sync a database with entitiy declaration above.
Expected behaviour
The column should be nullable.
Media prove
No response
Database
MySQL
Your environment
Additional context
No response