Skip to content

Fix for duplicating parent relation columns to child tables in JTI#100

Merged
roxblnfk merged 19 commits into
cycle:4.xfrom
peldax:patch-1
May 18, 2026
Merged

Fix for duplicating parent relation columns to child tables in JTI#100
roxblnfk merged 19 commits into
cycle:4.xfrom
peldax:patch-1

Conversation

@peldax

@peldax peldax commented Jun 21, 2024

Copy link
Copy Markdown
Contributor

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..

@peldax

peldax commented Jun 21, 2024

Copy link
Copy Markdown
Contributor Author

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.

@peldax

peldax commented Jun 21, 2024

Copy link
Copy Markdown
Contributor Author

Tests in CI fail due to phpunit deprecation, it is still needed to add a new testcases to cover the relevant usecases though.

@roxblnfk

roxblnfk commented Jun 21, 2024

Copy link
Copy Markdown
Member

To fix tests try to set mysql:8.0.37 there

image: mysql:latest

@peldax

peldax commented Jun 21, 2024

Copy link
Copy Markdown
Contributor Author

Sure, right now I am working on a fix to #101 as it is somewhat related.

@peldax

peldax commented Jun 21, 2024

Copy link
Copy Markdown
Contributor Author

In 90989a4 I implemented a logic to lookup an entity which truly owns the property.

This solves various issues:

  • Relations from JTI parent are not included in the child entity in case of JTI (the original purpose of this PR)
    • Relations from base class which is not an entity should be included normally.
  • Columns from parent/base classes are correctly included in the table schema.

@peldax

peldax commented Jun 23, 2024

Copy link
Copy Markdown
Contributor Author

@roxblnfk Hi, I have downgraded mysql to 8.0 and also resolved the PHPUnit deprecation. However, there are 2 failing tests related to the proxyFieldWithAnnotation and I am currently not sure what that means. Would you please help me to resolve the final bits in order to mainstream the fixes introduced in this PR?

@roxblnfk

roxblnfk commented Jun 24, 2024

Copy link
Copy Markdown
Member

Hi. It looks like this warning (Note) has gone off 😃

image

You can adjust this test for the new behavior if we talk about this:

Failed asserting that 'value' is null.
tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php:128

@roxblnfk

roxblnfk commented Jun 24, 2024

Copy link
Copy Markdown
Member

Hm.. The inheritance tests aren't passed even on the main branche

Looks like this assertion has unnecessary check isset($parent)

\assert($child->getRole() !== null && $entity !== null && isset($parent));

But I`m not sure

@peldax

peldax commented Jun 24, 2024

Copy link
Copy Markdown
Contributor Author

Hi. It looks like this warning (Note) has gone off 😃

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.

@peldax

peldax commented Jun 24, 2024

Copy link
Copy Markdown
Contributor Author

Hm.. The inheritance tests aren't passed even on the main branche

Looks like this assertion has extra check isset($parent)

\assert($child->getRole() !== null && $entity !== null && isset($parent));

But I`m not sure

I am also not sure about that part. The edits from maintainers are allowed, so feel free to jump into my branch.

@peldax

peldax commented Jun 25, 2024

Copy link
Copy Markdown
Contributor Author

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.

@peldax

peldax commented Jul 1, 2024

Copy link
Copy Markdown
Contributor Author

Hi, I would love to see this patch to land into a release. :shipit:

@roxblnfk

roxblnfk commented Jul 1, 2024

Copy link
Copy Markdown
Member

Hello. Do these changes require additional testing?
If not, then I'll review it again and merge.

@peldax

peldax commented Jul 1, 2024

Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/Configurator.php Outdated
@peldax

peldax commented Oct 17, 2024

Copy link
Copy Markdown
Contributor Author

@roxblnfk Hi,
Feel free to take over from here and alter the patch according to your needs, I am no longer using Cycle and will not invest time to implement the comments from your latest review.

@roxblnfk

Copy link
Copy Markdown
Member

@roxblnfk Hi, Feel free to take over from here and alter the patch according to your needs, I am no longer using Cycle and will not invest time to implement the comments from your latest review.

Thank you for bringing this to my attention. And thank you for the work you've done.

roxblnfk and others added 2 commits November 4, 2025 12:29
# Conflicts:
#	tests/Annotated/Fixtures/Fixtures16/Person.php
#	tests/Annotated/Functional/Driver/Common/BaseTestCase.php
#	tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php
#	tests/docker-compose.yml
@roxblnfk

roxblnfk commented Nov 4, 2025

Copy link
Copy Markdown
Member

For those interested in completing the fix: the code is saved in the jti-parent-columns-duplication branch.
Feel free to open a pull request to this branch.

@roxblnfk roxblnfk merged commit dde50bd into cycle:4.x May 18, 2026
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants