You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I'm trying to create a custom filter that simply adds a special OrderBy to the QueryBuilder. This query requires the use of HIDDEN fields so Doctrine can sort by them. This query works in my non-api code. However, api-platform seems to think these values are joins and not fields and thus throws an exception of The alias "..." does not exist in the QueryBuilder..
How to reproduce
protectedfunctionfilterProperty(string$property, $value, QueryBuilder$queryBuilder, QueryNameGeneratorInterface$queryNameGenerator, string$resourceClass, ?Operation$operation = null, array$context = []): void
{
if ($property !== $this->searchTerm || !is_array($value)) {
return;
}
if (!empty($value['template_order'])) {
$a = $queryBuilder->getRootAliases()[0];
$queryBuilder
->addSelect("CASE WHEN $a.enabled = 1 THEN 0 ELSE 1 END AS HIDDEN enabled")
->addSelect("CASE WHEN $a.quick = 1 THEN 0 ELSE 1 END AS HIDDEN quick")
->orderBy("enabled, quick, $a.title");
}
}
Possible Solution
Additional Context
The text was updated successfully, but these errors were encountered:
API Platform version(s) affected: 3.2.14
Description
I'm trying to create a custom filter that simply adds a special OrderBy to the QueryBuilder. This query requires the use of
HIDDEN
fields so Doctrine can sort by them. This query works in my non-api code. However, api-platform seems to think these values are joins and not fields and thus throws an exception ofThe alias "..." does not exist in the QueryBuilder.
.How to reproduce
Possible Solution
Additional Context
The text was updated successfully, but these errors were encountered: