Closed leevigraham closed 2 years ago
Thanks @brandonkelly for helping me debug. Turns out there were default values in the db column definition that where populating not related row data. This data was being pulled during the query and overwriting the correct data.
Description
Bit of a strange one… Here's the story…
We update a site from Craft2 to Craft 3.7.13.
In a single matrix field we have matrix blocks that contain fields that have the same handle:
Content is saved to the
matrixcontent_fieldName
table correctly in the correct columns:However when the data is retrieved from the BlockQuery and the rows are populated the data is wrong.
I've traced this down to
ElelementQuery::createElement
There's actually a comment that addresses this:
On line 1887 the value is being set based on the fieldHandle (which is not unique)
First matrix field with
mobileLayout
field handle:Second matrix field with
mobileLayout
field handle:Third matrix field with
mobileLayout
field handle:In the example above the context changes:
Once the data has been merged we end up with one value for
mobileLayout
The query is correct:
Possibly related:
https://craftcms.com/knowledge-base/upgrading-to-craft-3-7#randomized-database-column-names https://github.com/craftcms/cms/issues/6922