1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +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:
epriestley 2015-04-11 19:00:53 -07:00
parent a40c40fade
commit 4fba6e7730
8 changed files with 42 additions and 27 deletions

View file

@ -331,8 +331,8 @@ final class PhabricatorFileQuery
return $this->formatWhereClause($where);
}
protected function getPagingColumn() {
return 'f.id';
protected function getPrimaryTableAlias() {
return 'f';
}
public function getQueryApplicationClass() {

View file

@ -225,8 +225,8 @@ final class PhabricatorMacroQuery
return $macros;
}
protected function getPagingColumn() {
return 'm.id';
protected function getPrimaryTableAlias() {
return 'm';
}
public function getQueryApplicationClass() {

View file

@ -1137,8 +1137,8 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery {
));
}
protected function getApplicationSearchObjectPHIDColumn() {
return 'task.phid';
protected function getPrimaryTableAlias() {
return 'task';
}
public function getQueryApplicationClass() {

View file

@ -114,12 +114,8 @@ final class PhabricatorMetaMTAApplicationEmailQuery
return $this->formatWhereClause($where);
}
protected function getPagingColumn() {
return 'appemail.id';
}
protected function getApplicationSearchObjectPHIDColumn() {
return 'appemail.phid';
protected function getPrimaryTableAlias() {
return 'appemail';
}
public function getQueryApplicationClass() {

View file

@ -288,12 +288,8 @@ final class PhabricatorPeopleQuery
return $this->formatWhereClause($where);
}
protected function getPagingColumn() {
return 'user.id';
}
protected function getApplicationSearchObjectPHIDColumn() {
return 'user.phid';
protected function getPrimaryTableAlias() {
return 'user';
}
public function getQueryApplicationClass() {

View file

@ -380,8 +380,8 @@ final class PhabricatorProjectQuery
return 'PhabricatorProjectApplication';
}
protected function getApplicationSearchObjectPHIDColumn() {
return 'p.phid';
protected function getPrimaryTableAlias() {
return 'p';
}
}

View file

@ -174,8 +174,8 @@ final class PhabricatorSlowvoteQuery
return implode(' ', $joins);
}
protected function getPagingColumn() {
return 'p.id';
protected function getPrimaryTableAlias() {
return 'p';
}
public function getQueryApplicationClass() {

View file

@ -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 )------------------------------------------------------------- */
@ -450,7 +465,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
return array(
'id' => array(
'table' => null,
'table' => $this->getPrimaryTableAlias(),
'column' => 'id',
'reverse' => false,
'type' => 'int',
@ -657,15 +672,23 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
/**
* 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
* query construction requires a table alias it may be something like
* `"task.phid"`.
* JOIN clauses. Normally (and by default) this is just `"phid"`, but it may
* be something more exotic.
*
* See @{method:getPrimaryTableAlias} if the column needs to be qualified with
* a table alias.
*
* @return string Column name.
* @task appsearch
*/
protected function getApplicationSearchObjectPHIDColumn() {
return 'phid';
if ($this->getPrimaryTableAlias()) {
$prefix = $this->getPrimaryTableAlias().'.';
} else {
$prefix = '';
}
return $prefix.'phid';
}