findRaw rename feature buggy
$data = wire()->pages->findRaw([
'template' => 'whatever',
], [
'id',
'title' => 'renamed',
'os.title',
], [
'nulls' => true,
'indexed' => false,
]);
As you can see the 'title' => 'renamed' will cause the os.title to also be renamed to renamed and it should be title
@BernhardBaumrock It looks to me like that's how it's supposed to work. Unless I'm forgetting something, I don't think you'd have another way to rename os.title, for instance. So it renames at whatever level it appears. If you comment out this line below then it would only rename 'title' at the root level:
https://github.com/processwire/processwire/blob/master/wire/core/PagesRaw.php#L1583
@ryancramerdesign thx for looking into this! I don't see a reason why it would rename deeper levels? In my example I'm building a table with a list of servers and their operating system and the hosting company.
the operating system is a page reference field and findRaw makes it a bit complicated to get the data in the format that I need and the rename issue is just a side effect I'd say.
What I'd really want to have is a list like this:
server | operating system | hoster
foo | 24.04 | hetzner
bar | 22.04 | netcup
when using title => 'server' to rename the server's title label then I'd get the label server for the operating system, which is nonsense.
So for my use case it would be great to support a syntax like this:
'title' => 'Server',
'os.title' => 'Operating System',
'hoster' => 'Hosting Company',
I tried the flat option, but I still get output with arrays which means I need to post-process the data with foreach in memory:
I understand that the nested structure is necessary for page fields to support multiple values but in many situations this is causing a lot of headaches for me and it would be a lot better to have a really "flat" output:
Do you see any chance to support this?