Skip to content

[9.x] Qualify the primary key in queries#806

Merged
duncanmcclean merged 2 commits into
statamic-rad-pack:9.xfrom
Jade-GG:bugfix/qualify-primary-key-9.x
Apr 13, 2026
Merged

[9.x] Qualify the primary key in queries#806
duncanmcclean merged 2 commits into
statamic-rad-pack:9.xfrom
Jade-GG:bugfix/qualify-primary-key-9.x

Conversation

@Jade-GG
Copy link
Copy Markdown
Contributor

@Jade-GG Jade-GG commented Apr 13, 2026

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_attribute table onto the catalog_eav_attribute table. The primary key of the eav_attribute table is called attribute_id, which is also the column name they use for the foreign key in catalog_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 new qualifiedPrimaryKey() 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 😅

Copy link
Copy Markdown
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@duncanmcclean duncanmcclean merged commit b7b5d8a into statamic-rad-pack:9.x Apr 13, 2026
15 checks passed
@github-actions
Copy link
Copy Markdown

Released as part of v9.4.3.

@Jade-GG Jade-GG deleted the bugfix/qualify-primary-key-9.x branch April 14, 2026 07:13
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