mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +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:
parent
82cf97ad65
commit
d890c03ac3
1 changed files with 24 additions and 24 deletions
|
@ -464,28 +464,28 @@ final class PhabricatorProjectQuery
|
|||
}
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'status IN (%Ld)',
|
||||
'project.status IN (%Ld)',
|
||||
$filter);
|
||||
}
|
||||
|
||||
if ($this->statuses !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'status IN (%Ls)',
|
||||
'project.status IN (%Ls)',
|
||||
$this->statuses);
|
||||
}
|
||||
|
||||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'id IN (%Ld)',
|
||||
'project.id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'phid IN (%Ls)',
|
||||
'project.phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ final class PhabricatorProjectQuery
|
|||
if ($this->names !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'name IN (%Ls)',
|
||||
'project.name IN (%Ls)',
|
||||
$this->names);
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ final class PhabricatorProjectQuery
|
|||
foreach ($this->namePrefixes as $name_prefix) {
|
||||
$parts[] = qsprintf(
|
||||
$conn,
|
||||
'name LIKE %>',
|
||||
'project.name LIKE %>',
|
||||
$name_prefix);
|
||||
}
|
||||
$where[] = qsprintf($conn, '%LO', $parts);
|
||||
|
@ -531,21 +531,21 @@ final class PhabricatorProjectQuery
|
|||
if ($this->icons !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'icon IN (%Ls)',
|
||||
'project.icon IN (%Ls)',
|
||||
$this->icons);
|
||||
}
|
||||
|
||||
if ($this->colors !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'color IN (%Ls)',
|
||||
'project.color IN (%Ls)',
|
||||
$this->colors);
|
||||
}
|
||||
|
||||
if ($this->parentPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'parentProjectPHID IN (%Ls)',
|
||||
'project.parentProjectPHID IN (%Ls)',
|
||||
$this->parentPHIDs);
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ final class PhabricatorProjectQuery
|
|||
foreach ($ancestor_paths as $ancestor_path) {
|
||||
$sql[] = qsprintf(
|
||||
$conn,
|
||||
'(projectPath LIKE %> AND projectDepth > %d)',
|
||||
'(project.projectPath LIKE %> AND project.projectDepth > %d)',
|
||||
$ancestor_path['projectPath'],
|
||||
$ancestor_path['projectDepth']);
|
||||
}
|
||||
|
@ -572,18 +572,18 @@ final class PhabricatorProjectQuery
|
|||
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'parentProjectPHID IS NOT NULL');
|
||||
'project.parentProjectPHID IS NOT NULL');
|
||||
}
|
||||
|
||||
if ($this->isMilestone !== null) {
|
||||
if ($this->isMilestone) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'milestoneNumber IS NOT NULL');
|
||||
'project.milestoneNumber IS NOT NULL');
|
||||
} else {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'milestoneNumber IS NULL');
|
||||
'project.milestoneNumber IS NULL');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -591,42 +591,42 @@ final class PhabricatorProjectQuery
|
|||
if ($this->hasSubprojects !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'hasSubprojects = %d',
|
||||
'project.hasSubprojects = %d',
|
||||
(int)$this->hasSubprojects);
|
||||
}
|
||||
|
||||
if ($this->minDepth !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'projectDepth >= %d',
|
||||
'project.projectDepth >= %d',
|
||||
$this->minDepth);
|
||||
}
|
||||
|
||||
if ($this->maxDepth !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'projectDepth <= %d',
|
||||
'project.projectDepth <= %d',
|
||||
$this->maxDepth);
|
||||
}
|
||||
|
||||
if ($this->minMilestoneNumber !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'milestoneNumber >= %d',
|
||||
'project.milestoneNumber >= %d',
|
||||
$this->minMilestoneNumber);
|
||||
}
|
||||
|
||||
if ($this->maxMilestoneNumber !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'milestoneNumber <= %d',
|
||||
'project.milestoneNumber <= %d',
|
||||
$this->maxMilestoneNumber);
|
||||
}
|
||||
|
||||
if ($this->subtypes !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'subtype IN (%Ls)',
|
||||
'project.subtype IN (%Ls)',
|
||||
$this->subtypes);
|
||||
}
|
||||
|
||||
|
@ -646,7 +646,7 @@ final class PhabricatorProjectQuery
|
|||
if ($this->memberPHIDs !== null) {
|
||||
$joins[] = qsprintf(
|
||||
$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,
|
||||
PhabricatorProjectMaterializedMemberEdgeType::EDGECONST);
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ final class PhabricatorProjectQuery
|
|||
if ($this->watcherPHIDs !== null) {
|
||||
$joins[] = qsprintf(
|
||||
$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,
|
||||
PhabricatorObjectHasWatcherEdgeType::EDGECONST);
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ final class PhabricatorProjectQuery
|
|||
if ($this->slugs !== null) {
|
||||
$joins[] = qsprintf(
|
||||
$conn,
|
||||
'JOIN %T slug on slug.projectPHID = p.phid',
|
||||
'JOIN %T slug on slug.projectPHID = project.phid',
|
||||
id(new PhabricatorProjectSlug())->getTableName());
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ final class PhabricatorProjectQuery
|
|||
$token_table = 'token_'.$key;
|
||||
$joins[] = qsprintf(
|
||||
$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,
|
||||
$token_table,
|
||||
$token_table,
|
||||
|
@ -689,7 +689,7 @@ final class PhabricatorProjectQuery
|
|||
}
|
||||
|
||||
protected function getPrimaryTableAlias() {
|
||||
return 'p';
|
||||
return 'project';
|
||||
}
|
||||
|
||||
private function linkProjectGraph(array $projects, array $ancestors) {
|
||||
|
|
Loading…
Reference in a new issue