[9.x] Qualify the primary key in queries#806
Merged
duncanmcclean merged 2 commits intoApr 13, 2026
Merged
Conversation
|
Released as part of v9.4.3. |
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.
This fixes an edge case that occurs when you have a resource where querying it requires disambiguating (qualifying) the primary key. For example, the specific case we ran into was using product attributes from Magento. Within our code, we join the
eav_attributetable onto thecatalog_eav_attributetable. The primary key of theeav_attributetable is calledattribute_id, which is also the column name they use for the foreign key incatalog_eav_attribute.This is (unfortunately) a rather common occurrence in Magento so we often already have to qualify columns everywhere. However, we run into an issue with Runway because it currently assumes primary keys don't need to be qualified when it does queries.
I couldn't change the
primaryKey()function itself as it also gets used outside of queries, so instead I made a newqualifiedPrimaryKey()function. I think I caught all of the usages of the function here that relate to querying.Note: I have not written a test for this right now, as it would require modifying the testing database/migrations structure to fit this specific edge case. That seemed overkill, and frankly just a little bit out of my wheelhouse 😅