Page MenuHomePhabricator

D18785.diff
No OneTemporary

D18785.diff

diff --git a/src/applications/legalpad/query/LegalpadDocumentQuery.php b/src/applications/legalpad/query/LegalpadDocumentQuery.php
--- a/src/applications/legalpad/query/LegalpadDocumentQuery.php
+++ b/src/applications/legalpad/query/LegalpadDocumentQuery.php
@@ -77,23 +77,12 @@
return $this;
}
- protected function loadPage() {
- $table = new LegalpadDocument();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT d.* FROM %T d %Q %Q %Q %Q %Q',
- $table->getTableName(),
- $this->buildJoinClause($conn_r),
- $this->buildWhereClause($conn_r),
- $this->buildGroupClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- $documents = $table->loadAllFromArray($data);
+ public function newResultObject() {
+ return new LegalpadDocument();
+ }
- return $documents;
+ protected function loadPage() {
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $documents) {
@@ -134,12 +123,12 @@
return $documents;
}
- protected function buildJoinClause(AphrontDatabaseConnection $conn_r) {
- $joins = array();
+ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+ $joins = parent::buildJoinClauseParts($conn);
if ($this->contributorPHIDs !== null) {
$joins[] = qsprintf(
- $conn_r,
+ $conn,
'JOIN edge contributor ON contributor.src = d.phid
AND contributor.type = %d',
PhabricatorObjectHasContributorEdgeType::EDGECONST);
@@ -147,79 +136,81 @@
if ($this->signerPHIDs !== null) {
$joins[] = qsprintf(
- $conn_r,
+ $conn,
'JOIN %T signer ON signer.documentPHID = d.phid
AND signer.signerPHID IN (%Ls)',
id(new LegalpadDocumentSignature())->getTableName(),
$this->signerPHIDs);
}
- return implode(' ', $joins);
+ return $joins;
}
- protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
- if ($this->contributorPHIDs || $this->signerPHIDs) {
- return 'GROUP BY d.id';
- } else {
- return '';
+ protected function shouldGroupQueryResultRows() {
+ if ($this->contributorPHIDs) {
+ return true;
}
+
+ if ($this->signerPHIDs) {
+ return true;
+ }
+
+ return parent::shouldGroupQueryResultRows();
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.phid IN (%Ls)',
$this->phids);
}
if ($this->creatorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.creatorPHID IN (%Ls)',
$this->creatorPHIDs);
}
if ($this->dateCreatedAfter !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.dateCreated >= %d',
$this->dateCreatedAfter);
}
if ($this->dateCreatedBefore !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.dateCreated <= %d',
$this->dateCreatedBefore);
}
if ($this->contributorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'contributor.dst IN (%Ls)',
$this->contributorPHIDs);
}
if ($this->signatureRequired !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.requireSignature = %d',
$this->signatureRequired);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
private function loadDocumentBodies(array $documents) {
@@ -275,4 +266,8 @@
return 'PhabricatorLegalpadApplication';
}
+ protected function getPrimaryTableAlias() {
+ return 'd';
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Fri, May 24, 4:35 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6297033
Default Alt Text
D18785.diff (4 KB)

Event Timeline