diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php --- a/src/applications/repository/query/PhabricatorRepositoryQuery.php +++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php @@ -304,24 +304,28 @@ 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 @@ } $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 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -310,12 +310,21 @@ $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); + } } }