-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OrderBy (and others) not working with aliased fields #127
Comments
Same problem for the comparisons on aliased fields. |
Let's see if we can support aliased fields. Can you give an example query using specs that you would like to work? |
@Nyholm the simplest way would to not add alias if it is empty in this case i can add some complex field (with SUM, CASE, etc) into select and use it later in specs |
Now you can order by aliases: // DQL: SELECT e, e.posts_count + e.likes_count HIDDEN score FROM User e ORDER BY score
$spec = Spec::andX(
Spec::addSelect(
Spec::selectHiddenAs(
Spec::add(Spec::field('posts_count'), Spec::field('likes_count')),
'score'
)
),
Spec::orderBy(
Spec::alias('score')
)
); |
The OrderBy Query Modifier (and others) does not support using aliased fields.
$qb->addOrderBy(sprintf('%s.%s', $dqlAlias, $this->field), $this->order);
This line enforces a table.field regardless of the dqlAlias passed in. Whereas I will often want to order on an aliased field (with no dot).
The text was updated successfully, but these errors were encountered: