Repository navigation
fix poulate on parallel relations - #176
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
When a table has two relations to the same table, populating both of them creates wrong queries, where in
SELECTthe columns from the first relation will be used twice.: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(formallyleftPhpName) andjoinIdentifier(formallyrightPhpName), 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.