Closed martinherweg closed 1 year ago
Just for a sanity check, do you get the same output when using Craft's native dump
function or dd
tag?
Assuming the output is the same, do you have any custom code that might be interfering with eager loading? Could you also specify the field type of each of the eager loaded elements (heroImage
, topics
, and category
)?
@brianjhanson Yes same for dump
or dd
tag
I test this on a new template without any block nor extending anything so it's solely the query because that was my first assumption as well that there is something getting in the way.
heroImage
is an assets field
category
is an Entries field
topics
is an Entries field
I want to say again that it works fine in another envrionment, so it might be something with the database? The company I'm working at also has a support plan so I could open a case there and send you a database there.
That'd be great. If it works somewhere it definitely sounds like an environment issue.
👍 Thanks brian I'll do that tomorrow.
Sounds like the one and only @olivierbon helped you get things back on track.
For other's wandering into this thread, the issue ended up being two fields with the same handle. The fix was to remove one of the fields and manually fix things up.
What happened?
Description
I have a query like this
The result of the dump is null for all elements, the topics are Entries and are surely set on these elements and the category for example works fine when eager loaded. If I remove topics from the .with() I get results as wished.
I also have two different environments and it works on one and not on the other.
Expected behavior
news.topics.one()
should return the element when eager loadedActual behavior
Craft CMS version
4.3.1
PHP version
8.0.25
Operating system and version
Linux 5.10.0-0.bpo.15-amd64
Database type and version
MySQL 10.3.36
Image driver and version
No response
Installed plugins and versions