What happened?
Description
When trying to do an advanced element query calling a custom field in the select statement, I get an SQL error if I give the custom field a column alias.
This works
{% set critters = craft.entries()
.section('critters')
.orderBy('title')
.limit(null)
.select(['title as t', 'scientificName'])
.asArray()
.all() %}
This doesn't work
{% set critters = craft.entries()
.section('critters')
.orderBy('title')
.limit(null)
.select(['title as t', 'scientificName as l'])
.asArray()
.all() %}
Note the as l for the scientificName custom field.
Expected behavior
An array of objects with keys t and l
Actual behavior
SQL error: Column not found: 1054 Unknown column 'scientificName' in 'field list'.
Craft CMS version
5.4.6
PHP version
8.3.10
Operating system and version
No response
Database type and version
mysql 8.0
Image driver and version
No response
Installed plugins and versions
No response
What happened?
Description
When trying to do an advanced element query calling a custom field in the
selectstatement, I get an SQL error if I give the custom field a column alias.This works
This doesn't work
Note the
as lfor thescientificNamecustom field.Expected behavior
An array of objects with keys
tandlActual behavior
SQL error:
Column not found: 1054 Unknown column 'scientificName' in 'field list'.Craft CMS version
5.4.6
PHP version
8.3.10
Operating system and version
No response
Database type and version
mysql 8.0
Image driver and version
No response
Installed plugins and versions
No response