1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Namespace all column references in ProjectQuery to fix ambiguity with Ferret constraints

Summary:
Fixes T13378. If we join Ferret tables and page, we can end up with an ambiguous `id` column here.

Explicitly refer to "project.x" in all cases that we're interacting with the project table.

Test Plan:
  - Changed page size to 3.
  - Issued a Projects query for "~e", matching more than 3 results.
  - Clicked "Next Page".
    - Before: ambiguous id column fatal.
    - After: next page.

Maniphest Tasks: T13378

Differential Revision: https://secure.phabricator.com/D20714
This commit is contained in:
epriestley 2019-08-15 12:00:16 -07:00
parent 82cf97ad65
commit d890c03ac3

View file

@ -464,28 +464,28 @@ final class PhabricatorProjectQuery
} }
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'status IN (%Ld)', 'project.status IN (%Ld)',
$filter); $filter);
} }
if ($this->statuses !== null) { if ($this->statuses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'status IN (%Ls)', 'project.status IN (%Ls)',
$this->statuses); $this->statuses);
} }
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'id IN (%Ld)', 'project.id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'phid IN (%Ls)', 'project.phid IN (%Ls)',
$this->phids); $this->phids);
} }
@ -513,7 +513,7 @@ final class PhabricatorProjectQuery
if ($this->names !== null) { if ($this->names !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'name IN (%Ls)', 'project.name IN (%Ls)',
$this->names); $this->names);
} }
@ -522,7 +522,7 @@ final class PhabricatorProjectQuery
foreach ($this->namePrefixes as $name_prefix) { foreach ($this->namePrefixes as $name_prefix) {
$parts[] = qsprintf( $parts[] = qsprintf(
$conn, $conn,
'name LIKE %>', 'project.name LIKE %>',
$name_prefix); $name_prefix);
} }
$where[] = qsprintf($conn, '%LO', $parts); $where[] = qsprintf($conn, '%LO', $parts);
@ -531,21 +531,21 @@ final class PhabricatorProjectQuery
if ($this->icons !== null) { if ($this->icons !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'icon IN (%Ls)', 'project.icon IN (%Ls)',
$this->icons); $this->icons);
} }
if ($this->colors !== null) { if ($this->colors !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'color IN (%Ls)', 'project.color IN (%Ls)',
$this->colors); $this->colors);
} }
if ($this->parentPHIDs !== null) { if ($this->parentPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'parentProjectPHID IN (%Ls)', 'project.parentProjectPHID IN (%Ls)',
$this->parentPHIDs); $this->parentPHIDs);
} }
@ -563,7 +563,7 @@ final class PhabricatorProjectQuery
foreach ($ancestor_paths as $ancestor_path) { foreach ($ancestor_paths as $ancestor_path) {
$sql[] = qsprintf( $sql[] = qsprintf(
$conn, $conn,
'(projectPath LIKE %> AND projectDepth > %d)', '(project.projectPath LIKE %> AND project.projectDepth > %d)',
$ancestor_path['projectPath'], $ancestor_path['projectPath'],
$ancestor_path['projectDepth']); $ancestor_path['projectDepth']);
} }
@ -572,18 +572,18 @@ final class PhabricatorProjectQuery
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'parentProjectPHID IS NOT NULL'); 'project.parentProjectPHID IS NOT NULL');
} }
if ($this->isMilestone !== null) { if ($this->isMilestone !== null) {
if ($this->isMilestone) { if ($this->isMilestone) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'milestoneNumber IS NOT NULL'); 'project.milestoneNumber IS NOT NULL');
} else { } else {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'milestoneNumber IS NULL'); 'project.milestoneNumber IS NULL');
} }
} }
@ -591,42 +591,42 @@ final class PhabricatorProjectQuery
if ($this->hasSubprojects !== null) { if ($this->hasSubprojects !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'hasSubprojects = %d', 'project.hasSubprojects = %d',
(int)$this->hasSubprojects); (int)$this->hasSubprojects);
} }
if ($this->minDepth !== null) { if ($this->minDepth !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'projectDepth >= %d', 'project.projectDepth >= %d',
$this->minDepth); $this->minDepth);
} }
if ($this->maxDepth !== null) { if ($this->maxDepth !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'projectDepth <= %d', 'project.projectDepth <= %d',
$this->maxDepth); $this->maxDepth);
} }
if ($this->minMilestoneNumber !== null) { if ($this->minMilestoneNumber !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'milestoneNumber >= %d', 'project.milestoneNumber >= %d',
$this->minMilestoneNumber); $this->minMilestoneNumber);
} }
if ($this->maxMilestoneNumber !== null) { if ($this->maxMilestoneNumber !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'milestoneNumber <= %d', 'project.milestoneNumber <= %d',
$this->maxMilestoneNumber); $this->maxMilestoneNumber);
} }
if ($this->subtypes !== null) { if ($this->subtypes !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'subtype IN (%Ls)', 'project.subtype IN (%Ls)',
$this->subtypes); $this->subtypes);
} }
@ -646,7 +646,7 @@ final class PhabricatorProjectQuery
if ($this->memberPHIDs !== null) { if ($this->memberPHIDs !== null) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn, $conn,
'JOIN %T e ON e.src = p.phid AND e.type = %d', 'JOIN %T e ON e.src = project.phid AND e.type = %d',
PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorEdgeConfig::TABLE_NAME_EDGE,
PhabricatorProjectMaterializedMemberEdgeType::EDGECONST); PhabricatorProjectMaterializedMemberEdgeType::EDGECONST);
} }
@ -654,7 +654,7 @@ final class PhabricatorProjectQuery
if ($this->watcherPHIDs !== null) { if ($this->watcherPHIDs !== null) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn, $conn,
'JOIN %T w ON w.src = p.phid AND w.type = %d', 'JOIN %T w ON w.src = project.phid AND w.type = %d',
PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorEdgeConfig::TABLE_NAME_EDGE,
PhabricatorObjectHasWatcherEdgeType::EDGECONST); PhabricatorObjectHasWatcherEdgeType::EDGECONST);
} }
@ -662,7 +662,7 @@ final class PhabricatorProjectQuery
if ($this->slugs !== null) { if ($this->slugs !== null) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn, $conn,
'JOIN %T slug on slug.projectPHID = p.phid', 'JOIN %T slug on slug.projectPHID = project.phid',
id(new PhabricatorProjectSlug())->getTableName()); id(new PhabricatorProjectSlug())->getTableName());
} }
@ -672,7 +672,7 @@ final class PhabricatorProjectQuery
$token_table = 'token_'.$key; $token_table = 'token_'.$key;
$joins[] = qsprintf( $joins[] = qsprintf(
$conn, $conn,
'JOIN %T %T ON %T.projectID = p.id AND %T.token LIKE %>', 'JOIN %T %T ON %T.projectID = project.id AND %T.token LIKE %>',
PhabricatorProject::TABLE_DATASOURCE_TOKEN, PhabricatorProject::TABLE_DATASOURCE_TOKEN,
$token_table, $token_table,
$token_table, $token_table,
@ -689,7 +689,7 @@ final class PhabricatorProjectQuery
} }
protected function getPrimaryTableAlias() { protected function getPrimaryTableAlias() {
return 'p'; return 'project';
} }
private function linkProjectGraph(array $projects, array $ancestors) { private function linkProjectGraph(array $projects, array $ancestors) {