@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+42 -27
+2 -2
src/applications/files/query/PhabricatorFileQuery.php
··· 331 331 return $this->formatWhereClause($where); 332 332 } 333 333 334 - protected function getPagingColumn() { 335 - return 'f.id'; 334 + protected function getPrimaryTableAlias() { 335 + return 'f'; 336 336 } 337 337 338 338 public function getQueryApplicationClass() {
+2 -2
src/applications/macro/query/PhabricatorMacroQuery.php
··· 225 225 return $macros; 226 226 } 227 227 228 - protected function getPagingColumn() { 229 - return 'm.id'; 228 + protected function getPrimaryTableAlias() { 229 + return 'm'; 230 230 } 231 231 232 232 public function getQueryApplicationClass() {
+2 -2
src/applications/maniphest/query/ManiphestTaskQuery.php
··· 1137 1137 )); 1138 1138 } 1139 1139 1140 - protected function getApplicationSearchObjectPHIDColumn() { 1141 - return 'task.phid'; 1140 + protected function getPrimaryTableAlias() { 1141 + return 'task'; 1142 1142 } 1143 1143 1144 1144 public function getQueryApplicationClass() {
+2 -6
src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
··· 114 114 return $this->formatWhereClause($where); 115 115 } 116 116 117 - protected function getPagingColumn() { 118 - return 'appemail.id'; 119 - } 120 - 121 - protected function getApplicationSearchObjectPHIDColumn() { 122 - return 'appemail.phid'; 117 + protected function getPrimaryTableAlias() { 118 + return 'appemail'; 123 119 } 124 120 125 121 public function getQueryApplicationClass() {
+2 -6
src/applications/people/query/PhabricatorPeopleQuery.php
··· 288 288 return $this->formatWhereClause($where); 289 289 } 290 290 291 - protected function getPagingColumn() { 292 - return 'user.id'; 293 - } 294 - 295 - protected function getApplicationSearchObjectPHIDColumn() { 296 - return 'user.phid'; 291 + protected function getPrimaryTableAlias() { 292 + return 'user'; 297 293 } 298 294 299 295 public function getQueryApplicationClass() {
+2 -2
src/applications/project/query/PhabricatorProjectQuery.php
··· 380 380 return 'PhabricatorProjectApplication'; 381 381 } 382 382 383 - protected function getApplicationSearchObjectPHIDColumn() { 384 - return 'p.phid'; 383 + protected function getPrimaryTableAlias() { 384 + return 'p'; 385 385 } 386 386 387 387 }
+2 -2
src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
··· 174 174 return implode(' ', $joins); 175 175 } 176 176 177 - protected function getPagingColumn() { 178 - return 'p.id'; 177 + protected function getPrimaryTableAlias() { 178 + return 'p'; 179 179 } 180 180 181 181 public function getQueryApplicationClass() {
+28 -5
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 147 147 } 148 148 149 149 150 + /** 151 + * Return the alias this query uses to identify the primary table. 152 + * 153 + * Some automatic query constructions may need to be qualified with a table 154 + * alias if the query performs joins which make column names ambiguous. If 155 + * this is the case, return the alias for the primary table the query 156 + * uses; generally the object table which has `id` and `phid` columns. 157 + * 158 + * @return string Alias for the primary table. 159 + */ 160 + protected function getPrimaryTableAlias() { 161 + return null; 162 + } 163 + 164 + 150 165 /* -( Paging )------------------------------------------------------------- */ 151 166 152 167 ··· 450 465 451 466 return array( 452 467 'id' => array( 453 - 'table' => null, 468 + 'table' => $this->getPrimaryTableAlias(), 454 469 'column' => 'id', 455 470 'reverse' => false, 456 471 'type' => 'int', ··· 657 672 658 673 /** 659 674 * Get the name of the query's primary object PHID column, for constructing 660 - * JOIN clauses. Normally (and by default) this is just `"phid"`, but if the 661 - * query construction requires a table alias it may be something like 662 - * `"task.phid"`. 675 + * JOIN clauses. Normally (and by default) this is just `"phid"`, but it may 676 + * be something more exotic. 677 + * 678 + * See @{method:getPrimaryTableAlias} if the column needs to be qualified with 679 + * a table alias. 663 680 * 664 681 * @return string Column name. 665 682 * @task appsearch 666 683 */ 667 684 protected function getApplicationSearchObjectPHIDColumn() { 668 - return 'phid'; 685 + if ($this->getPrimaryTableAlias()) { 686 + $prefix = $this->getPrimaryTableAlias().'.'; 687 + } else { 688 + $prefix = ''; 689 + } 690 + 691 + return $prefix.'phid'; 669 692 } 670 693 671 694