ConfigEntityQuery::addOrderBy is a little bit strange. If you define sorting for a view, the $field var is set. If you switch the sorting over table-sorting, then only the $alias var is set. So addOrderBy should work in both cases

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chr.fritsch created an issue. See original summary.

chr.fritsch’s picture

Status: Active » Needs review
FileSize
609 bytes

Here is a patch to fix it

vijaycs85’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/views/query/ConfigEntityQuery.php
@@ -81,7 +81,13 @@ class ConfigEntityQuery extends Sql {
+    if ($field) {

by the look of Drupal\views\Plugin\views\query\Sql::addOrderBy, $alias gets priority over field. Can we change the condition to check $alias first?

chr.fritsch’s picture

Status: Needs work » Needs review
FileSize
609 bytes

Yes, of course

vijaycs85’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

vijaycs85’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @chr.fritsch

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.