mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
Remove trivial implementations of getPagingColumn()
Summary: Ref T7803. Some Query subclasses implement getPagingColumn() in a trivial way, usually to provide a table alias. Formalize the concept of a primary table alias, and remove obsoleted getPagingColumn() implementations. Test Plan: Issued affected queries. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7803 Differential Revision: https://secure.phabricator.com/D12356
This commit is contained in:
parent
a40c40fade
commit
4fba6e7730
8 changed files with 42 additions and 27 deletions
|
@ -331,8 +331,8 @@ final class PhabricatorFileQuery
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPagingColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'f.id';
|
return 'f';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -225,8 +225,8 @@ final class PhabricatorMacroQuery
|
||||||
return $macros;
|
return $macros;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPagingColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'm.id';
|
return 'm';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -1137,8 +1137,8 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getApplicationSearchObjectPHIDColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'task.phid';
|
return 'task';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -114,12 +114,8 @@ final class PhabricatorMetaMTAApplicationEmailQuery
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPagingColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'appemail.id';
|
return 'appemail';
|
||||||
}
|
|
||||||
|
|
||||||
protected function getApplicationSearchObjectPHIDColumn() {
|
|
||||||
return 'appemail.phid';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -288,12 +288,8 @@ final class PhabricatorPeopleQuery
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPagingColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'user.id';
|
return 'user';
|
||||||
}
|
|
||||||
|
|
||||||
protected function getApplicationSearchObjectPHIDColumn() {
|
|
||||||
return 'user.phid';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -380,8 +380,8 @@ final class PhabricatorProjectQuery
|
||||||
return 'PhabricatorProjectApplication';
|
return 'PhabricatorProjectApplication';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getApplicationSearchObjectPHIDColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'p.phid';
|
return 'p';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,8 +174,8 @@ final class PhabricatorSlowvoteQuery
|
||||||
return implode(' ', $joins);
|
return implode(' ', $joins);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPagingColumn() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'p.id';
|
return 'p';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -147,6 +147,21 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the alias this query uses to identify the primary table.
|
||||||
|
*
|
||||||
|
* Some automatic query constructions may need to be qualified with a table
|
||||||
|
* alias if the query performs joins which make column names ambiguous. If
|
||||||
|
* this is the case, return the alias for the primary table the query
|
||||||
|
* uses; generally the object table which has `id` and `phid` columns.
|
||||||
|
*
|
||||||
|
* @return string Alias for the primary table.
|
||||||
|
*/
|
||||||
|
protected function getPrimaryTableAlias() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Paging )------------------------------------------------------------- */
|
/* -( Paging )------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -450,7 +465,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'id' => array(
|
'id' => array(
|
||||||
'table' => null,
|
'table' => $this->getPrimaryTableAlias(),
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
'reverse' => false,
|
'reverse' => false,
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
|
@ -657,15 +672,23 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the query's primary object PHID column, for constructing
|
* Get the name of the query's primary object PHID column, for constructing
|
||||||
* JOIN clauses. Normally (and by default) this is just `"phid"`, but if the
|
* JOIN clauses. Normally (and by default) this is just `"phid"`, but it may
|
||||||
* query construction requires a table alias it may be something like
|
* be something more exotic.
|
||||||
* `"task.phid"`.
|
*
|
||||||
|
* See @{method:getPrimaryTableAlias} if the column needs to be qualified with
|
||||||
|
* a table alias.
|
||||||
*
|
*
|
||||||
* @return string Column name.
|
* @return string Column name.
|
||||||
* @task appsearch
|
* @task appsearch
|
||||||
*/
|
*/
|
||||||
protected function getApplicationSearchObjectPHIDColumn() {
|
protected function getApplicationSearchObjectPHIDColumn() {
|
||||||
return 'phid';
|
if ($this->getPrimaryTableAlias()) {
|
||||||
|
$prefix = $this->getPrimaryTableAlias().'.';
|
||||||
|
} else {
|
||||||
|
$prefix = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $prefix.'phid';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue