コード例 #1
0
 /**
  * @task internal
  */
 private function buildJoinsClause($conn_r)
 {
     $joins = array();
     if ($this->pathIDs) {
         $path_table = new DifferentialAffectedPath();
         $joins[] = qsprintf($conn_r, 'JOIN %T p ON p.revisionID = r.id', $path_table->getTableName());
     }
     if ($this->commitHashes) {
         $joins[] = qsprintf($conn_r, 'JOIN %T hash_rel ON hash_rel.revisionID = r.id', ArcanistDifferentialRevisionHash::TABLE_NAME);
     }
     if ($this->ccs) {
         $joins[] = qsprintf($conn_r, 'JOIN %T e_ccs ON e_ccs.src = r.phid ' . 'AND e_ccs.type = %s ' . 'AND e_ccs.dst in (%Ls)', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorObjectHasSubscriberEdgeType::EDGECONST, $this->ccs);
     }
     if ($this->reviewers) {
         $joins[] = qsprintf($conn_r, 'JOIN %T e_reviewers ON e_reviewers.src = r.phid ' . 'AND e_reviewers.type = %s ' . 'AND e_reviewers.dst in (%Ls)', PhabricatorEdgeConfig::TABLE_NAME_EDGE, DifferentialRevisionHasReviewerEdgeType::EDGECONST, $this->reviewers);
     }
     if ($this->draftAuthors) {
         $differential_draft = new DifferentialDraft();
         $joins[] = qsprintf($conn_r, 'JOIN %T has_draft ON has_draft.objectPHID = r.phid ' . 'AND has_draft.authorPHID IN (%Ls)', $differential_draft->getTableName(), $this->draftAuthors);
     }
     if ($this->commitPHIDs) {
         $joins[] = qsprintf($conn_r, 'JOIN %T commits ON commits.revisionID = r.id', DifferentialRevision::TABLE_COMMIT);
     }
     $joins[] = $this->buildJoinClauseParts($conn_r);
     return $this->formatJoinClause($joins);
 }
コード例 #2
0
 /**
  * @task internal
  */
 private function buildJoinsClause($conn_r)
 {
     $joins = array();
     if ($this->pathIDs) {
         $path_table = new DifferentialAffectedPath();
         $joins[] = qsprintf($conn_r, 'JOIN %T p ON p.revisionID = r.id', $path_table->getTableName());
     }
     if ($this->commitHashes) {
         $joins[] = qsprintf($conn_r, 'JOIN %T hash_rel ON hash_rel.revisionID = r.id', ArcanistDifferentialRevisionHash::TABLE_NAME);
     }
     if ($this->ccs) {
         $joins[] = qsprintf($conn_r, 'JOIN %T e_ccs ON e_ccs.src = r.phid ' . 'AND e_ccs.type = %s ' . 'AND e_ccs.dst in (%Ls)', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER, $this->ccs);
     }
     if ($this->reviewers) {
         $joins[] = qsprintf($conn_r, 'JOIN %T e_reviewers ON e_reviewers.src = r.phid ' . 'AND e_reviewers.type = %s ' . 'AND e_reviewers.dst in (%Ls)', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER, $this->reviewers);
     }
     if ($this->draftAuthors) {
         $differential_draft = new DifferentialDraft();
         $joins[] = qsprintf($conn_r, 'JOIN %T has_draft ON has_draft.objectPHID = r.phid ' . 'AND has_draft.authorPHID IN (%Ls)', $differential_draft->getTableName(), $this->draftAuthors);
     }
     $joins = implode(' ', $joins);
     return $joins;
 }
コード例 #3
0
<?php

// Destroy duplicate drafts before storage adjustment adds a unique key to this
// table. See T1191. We retain the newest draft.
// (We can't easily do this in a single SQL statement because MySQL won't let us
// modify a table that's joined in a subquery.)
$table = new DifferentialDraft();
$conn_w = $table->establishConnection('w');
$duplicates = queryfx_all($conn_w, 'SELECT DISTINCT u.id id FROM %T u
    JOIN %T v
      ON u.objectPHID = v.objectPHID
      AND u.authorPHID = v.authorPHID
      AND u.draftKey = v.draftKey
      AND u.id < v.id', $table->getTableName(), $table->getTableName());
$duplicates = ipull($duplicates, 'id');
foreach (PhabricatorLiskDAO::chunkSQL($duplicates) as $chunk) {
    queryfx($conn_w, 'DELETE FROM %T WHERE id IN (%Q)', $table->getTableName(), $chunk);
}