-
-
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
Fix for duplicating parent relation columns to child tables in JTI #100
base: 4.x
Are you sure you want to change the base?
Conversation
In ad29886 I added a logic to identify whether the property belongs to current entity or any parent entity in the hierarchy. This renders the note above as resolved. |
Tests in CI fail due to phpunit deprecation, it is still needed to add a new testcases to cover the relevant usecases though. |
To fix tests try to set annotated/tests/docker-compose.yml Line 14 in 7dad356
|
Sure, right now I am working on a fix to #101 as it is somewhat related. |
In 90989a4 I implemented a logic to lookup an entity which truly owns the property. This solves various issues:
|
@roxblnfk Hi, I have downgraded mysql to 8.0 and also resolved the PHPUnit deprecation. However, there are 2 failing tests related to the |
Hm.. The inheritance tests aren't passed even on the main branche Looks like this assertion has unnecessary check annotated/src/TableInheritance.php Line 69 in 7dad356
But I`m not sure |
Yes, this is a side effect of this PR - to support base classes that are not entitites, but declare columns. Base classes can be placed anywehere in the table inheritance hierarchy and on as many levels as needed. |
I am also not sure about that part. The edits from maintainers are allowed, so feel free to jump into my branch. |
Hi @roxblnfk , thanks for looking into it! The metadata reader provider changes were made due to phpunits deprecation, which was introduced in 10.5.18. |
Hi, I would love to see this patch to land into a release. |
Hello. Do these changes require additional testing? |
Well, there is always a possibility to add additional automated tests. I am running this patch locally and so far it has been working well. |
if ($this->findOwningEntity($class, $property->getDeclaringClass())->getName() !== $class->getName()) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added tests for this case and there is an issue when an entity extended from another entity without STI or JTI.
In thos case all the relations of the parent entity have to be cloned into the child class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is TableInheritance
generator. It might be better to clean unnecessary relations there in cases STI or JTI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review.
You are right, it is quite a nasty use case though. I will take a look at it in the evening,
It makes sense to clear the entity in the inheritance generator, I will try to move the logic there.
The column ownership use cases are alright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, columns look great. Thank you.
@roxblnfk Hi, |
Thank you for bringing this to my attention. And thank you for the work you've done. |
Partial fix of #97
🔍 What was changed
I removed initialization of relations if the declaring class differs from currently processed reflection class. This solves a case from issue above, where BelongsTo relation column were duplicated to child tables as well.
📝 Checklist
📃 Documentation
Not needed, this is expected behaviour.
NOTE
This solution is just a hotfix identifying the problem. The real solution will be more complex as it probably needs to deduce whether the declaring class is really the parent entity or some other class in the hierarchy between the parent entity and the child entity..