From a653d4d9b3e1ea41df63cfa63146aef8b4fe5581 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 8 Jun 2016 07:33:53 -0700 Subject: [PATCH] Give ConpherenceThreadQuery a primary table alias Summary: Fixes T11113. On the 2nd+ page, we could end up with an ambiguous `id` WHERE clause because we don't define a primary table alias on this query. Define one. Test Plan: Changed SearchEngine to return pages of size 5, searched for my threads, toggled to second page, no exception. Used DarkConsole to examine that second-page query, saw that it had `thread.id` explicitly instead of `id` implicitly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11113 Differential Revision: https://secure.phabricator.com/D16080 --- .../conpherence/query/ConpherenceThreadQuery.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/applications/conpherence/query/ConpherenceThreadQuery.php b/src/applications/conpherence/query/ConpherenceThreadQuery.php index 7006ee759d..7ad653f486 100644 --- a/src/applications/conpherence/query/ConpherenceThreadQuery.php +++ b/src/applications/conpherence/query/ConpherenceThreadQuery.php @@ -100,7 +100,7 @@ final class ConpherenceThreadQuery $data = queryfx_all( $conn_r, - 'SELECT conpherence_thread.* FROM %T conpherence_thread %Q %Q %Q %Q %Q', + 'SELECT thread.* FROM %T thread %Q %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), @@ -144,7 +144,7 @@ final class ConpherenceThreadQuery protected function buildGroupClause(AphrontDatabaseConnection $conn_r) { if ($this->participantPHIDs !== null || strlen($this->fulltext)) { - return 'GROUP BY conpherence_thread.id'; + return 'GROUP BY thread.id'; } else { return $this->buildApplicationSearchGroupClause($conn_r); } @@ -156,14 +156,14 @@ final class ConpherenceThreadQuery if ($this->participantPHIDs !== null) { $joins[] = qsprintf( $conn_r, - 'JOIN %T p ON p.conpherencePHID = conpherence_thread.phid', + 'JOIN %T p ON p.conpherencePHID = thread.phid', id(new ConpherenceParticipant())->getTableName()); } if (strlen($this->fulltext)) { $joins[] = qsprintf( $conn_r, - 'JOIN %T idx ON idx.threadPHID = conpherence_thread.phid', + 'JOIN %T idx ON idx.threadPHID = thread.phid', id(new ConpherenceIndex())->getTableName()); } @@ -179,14 +179,14 @@ final class ConpherenceThreadQuery if ($this->ids !== null) { $where[] = qsprintf( $conn_r, - 'conpherence_thread.id IN (%Ld)', + 'thread.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn_r, - 'conpherence_thread.phid IN (%Ls)', + 'thread.phid IN (%Ls)', $this->phids); } @@ -438,4 +438,8 @@ final class ConpherenceThreadQuery return 'PhabricatorConpherenceApplication'; } + protected function getPrimaryTableAlias() { + return 'thread'; + } + }