1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Group query results under the "ANCESTOR" operator unconditionally

Summary:
Fixes T12753. See that task for reproduction instructions.

We add a `GROUP BY` clause to queries with an "ANCESTOR" edge constraint only if the constaint has more than one PHID, but this is incorrect: the same row can be found twice by an ANCESTOR query if task T is tagged with both "B" and "C", children of "A", and the user queries for "tasks in A".

Instead, always add GROUP BY for ANCESTOR queries.

Test Plan:
  - Followed test plan in T12753.
  - Saw proper paging controls after change.
  - Saw `GROUP BY` in DarkConsole.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12753

Differential Revision: https://secure.phabricator.com/D18012
This commit is contained in:
epriestley 2017-05-24 11:47:40 -07:00
parent 88466addee
commit 709c304d76

View file

@ -1811,11 +1811,16 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
case PhabricatorQueryConstraint::OPERATOR_NOT: case PhabricatorQueryConstraint::OPERATOR_NOT:
case PhabricatorQueryConstraint::OPERATOR_AND: case PhabricatorQueryConstraint::OPERATOR_AND:
case PhabricatorQueryConstraint::OPERATOR_OR: case PhabricatorQueryConstraint::OPERATOR_OR:
case PhabricatorQueryConstraint::OPERATOR_ANCESTOR:
if (count($list) > 1) { if (count($list) > 1) {
return true; return true;
} }
break; break;
case PhabricatorQueryConstraint::OPERATOR_ANCESTOR:
// NOTE: We must always group query results rows when using an
// "ANCESTOR" operator because a single task may be related to
// two different descendants of a particular ancestor. For
// discussion, see T12753.
return true;
case PhabricatorQueryConstraint::OPERATOR_NULL: case PhabricatorQueryConstraint::OPERATOR_NULL:
return true; return true;
} }