Skip to content

fix poulate on parallel relations - #176

Merged
mringler merged 2 commits into
perplorm:mainfrom
mringler:fix_parallel_join
Nov 4, 2026
Merged

mringler merged 2 commits into
perplorm:mainfrom
mringler:fix_parallel_join

Conversation

@mringler

Copy link
Copy Markdown
Collaborator

Issue

When a table has two relations to the same table, populating both of them creates wrong queries, where in SELECT the columns from the first relation will be used twice.:

        SELECT 
            couple.id,
            couple.person_1_id,
            couple.person_2_id,
            p1.id,
            p1.id --   <----------- should be p2.id
        FROM couple
        LEFT JOIN person p1 ON (couple.person_1_id=p1.id)
        LEFT JOIN person p2 ON (couple.person_2_id=p2.id)

Changes

The error happens when Perpl tries to resolve relation alias from table name, and the first match is always used.
Instead, the table reference in the query is made available, so it can be used directly.

Implementation Details

The class storing population details (RelationPopulator) now stores a reference to the Join object instead of just extracting relevant data during construction.

Also, the RelationPopulator matched naming of Join by referring to a left and a right side. This is used in the formatters to populate nested objects, when figuring out the parent model for the current object. I changed this to parentJoinIdentifier (formally leftPhpName) and joinIdentifier (formally rightPhpName), which I find more precise and easier to understand when reading code in the formatters.

Test strategy

Updated existing tests and added test checking generated query code.

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/Propel/Runtime/ActiveQuery/RelationPopulator.php 88.23% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mringler
mringler merged commit c6f2abb into perplorm:main Nov 4, 2026
42 checks passed
@mringler
mringler deleted the fix_parallel_join branch November 4, 2026 11:53
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.

1 participant