diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php index 8fe0aa9ab8..fe319cd8e6 100644 --- a/src/applications/repository/query/PhabricatorRepositoryQuery.php +++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php @@ -304,24 +304,28 @@ final class PhabricatorRepositoryQuery break; case self::ORDER_COMMITTED: $parts[] = array( - 'name' => 's.epoch', + 'table' => 's', + 'column' => 'epoch', ); break; case self::ORDER_CALLSIGN: $parts[] = array( - 'name' => 'r.callsign', + 'table' => 'r', + 'column' => 'callsign', 'reverse' => true, ); break; case self::ORDER_NAME: $parts[] = array( - 'name' => 'r.name', + 'table' => 'r', + 'column' => 'name', 'reverse' => true, ); break; case self::ORDER_SIZE: $parts[] = array( - 'name' => 's.size', + 'table' => 's', + 'column' => 'size', ); break; default: @@ -329,7 +333,8 @@ final class PhabricatorRepositoryQuery } $parts[] = array( - 'name' => 'r.id', + 'table' => 'r', + 'column' => 'id', ); return $this->formatOrderClause($conn, $parts); diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 18526123a3..42ea200de1 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -310,12 +310,21 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery $descending = !$descending; } - $name = $part['name']; + $table = idx($part, 'table'); + $column = $part['column']; if ($descending) { - $sql[] = qsprintf($conn, '%Q DESC', $name); + if ($table !== null) { + $sql[] = qsprintf($conn, '%T.%T DESC', $table, $column); + } else { + $sql[] = qsprintf($conn, '%T DESC', $column); + } } else { - $sql[] = qsprintf($conn, '%Q ASC', $name); + if ($table !== null) { + $sql[] = qsprintf($conn, '%T.%T ASC', $table, $column); + } else { + $sql[] = qsprintf($conn, '%T ASC', $column); + } } }