-
-
Notifications
You must be signed in to change notification settings - Fork 13
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]: HasOne overrides nullability of BelongsTo #97
Comments
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, |
It's nice to hear that. |
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 |
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
The text was updated successfully, but these errors were encountered: