1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Simplify UNION/ORDER query construction in DifferentialRevisionQuery

Summary: Ref T12680. Use the slightly sleeker construction from D18722 in Differential.

Test Plan: Viewed revision list, reordered by date modified.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T12680

Differential Revision: https://secure.phabricator.com/D18727
This commit is contained in:
epriestley 2017-10-23 14:59:32 -07:00
parent e3a48dde1d
commit 683df399e7

View file

@ -38,8 +38,6 @@ final class DifferentialRevisionQuery
private $needDrafts; private $needDrafts;
private $needFlags; private $needFlags;
private $buildingGlobalOrder;
/* -( Query Configuration )------------------------------------------------ */ /* -( Query Configuration )------------------------------------------------ */
@ -484,12 +482,11 @@ final class DifferentialRevisionQuery
} }
if (count($selects) > 1) { if (count($selects) > 1) {
$this->buildingGlobalOrder = true;
$query = qsprintf( $query = qsprintf(
$conn_r, $conn_r,
'%Q %Q %Q', '%Q %Q %Q',
implode(' UNION DISTINCT ', $selects), implode(' UNION DISTINCT ', $selects),
$this->buildOrderClause($conn_r), $this->buildOrderClause($conn_r, true),
$this->buildLimitClause($conn_r)); $this->buildLimitClause($conn_r));
} else { } else {
$query = head($selects); $query = head($selects);
@ -513,7 +510,6 @@ final class DifferentialRevisionQuery
$group_by = $this->buildGroupClause($conn_r); $group_by = $this->buildGroupClause($conn_r);
$having = $this->buildHavingClause($conn_r); $having = $this->buildHavingClause($conn_r);
$this->buildingGlobalOrder = false;
$order_by = $this->buildOrderClause($conn_r); $order_by = $this->buildOrderClause($conn_r);
$limit = $this->buildLimitClause($conn_r); $limit = $this->buildLimitClause($conn_r);
@ -758,17 +754,9 @@ final class DifferentialRevisionQuery
} }
public function getOrderableColumns() { public function getOrderableColumns() {
$primary = ($this->buildingGlobalOrder ? null : 'r');
return array( return array(
'id' => array(
'table' => $primary,
'column' => 'id',
'type' => 'int',
'unique' => true,
),
'updated' => array( 'updated' => array(
'table' => $primary, 'table' => $this->getPrimaryTableAlias(),
'column' => 'dateModified', 'column' => 'dateModified',
'type' => 'int', 'type' => 'int',
), ),