1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Update many Phabricator queries for new %Q query semantics

Summary: Depends on D19785. Ref T13217. This converts many of the most common clause construction pathways to the new %Q / %LQ / %LO / %LA / %LJ semantics.

Test Plan: Browsed around a bunch, saw fewer warnings and no obvious behavioral errors. The transformations here are generally mechanical (although I did them by hand).

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: hach-que

Maniphest Tasks: T13217

Differential Revision: https://secure.phabricator.com/D19789
This commit is contained in:
epriestley 2018-11-07 02:48:26 -08:00
parent 64b52b9952
commit 98690ee326
54 changed files with 407 additions and 417 deletions

View file

@ -59,26 +59,26 @@ final class PhabricatorAuthInviteQuery
return $invites;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->emailAddresses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'emailAddress IN (%Ls)',
$this->emailAddresses);
}
@ -90,21 +90,21 @@ final class PhabricatorAuthInviteQuery
}
$where[] = qsprintf(
$conn_r,
$conn,
'verificationHash IN (%Ls)',
$hashes);
}
if ($this->authorPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'authorPHID IN (%Ls)',
$this->authorPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -54,26 +54,26 @@ final class PhabricatorAuthProviderConfigQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->providerClasses) {
if ($this->providerClasses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'providerClass IN (%Ls)',
$this->providerClasses);
}
@ -84,16 +84,16 @@ final class PhabricatorAuthProviderConfigQuery
break;
case self::STATUS_ENABLED:
$where[] = qsprintf(
$conn_r,
$conn,
'isEnabled = 1');
break;
default:
throw new Exception(pht("Unknown status '%s'!", $status));
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -65,44 +65,44 @@ final class PhabricatorAuthSessionQuery
return $sessions;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->identityPHIDs) {
if ($this->identityPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'userPHID IN (%Ls)',
$this->identityPHIDs);
}
if ($this->sessionKeys) {
if ($this->sessionKeys !== null) {
$hashes = array();
foreach ($this->sessionKeys as $session_key) {
$hashes[] = PhabricatorHash::weakDigest($session_key);
}
$where[] = qsprintf(
$conn_r,
$conn,
'sessionKey IN (%Ls)',
$hashes);
}
if ($this->sessionTypes) {
if ($this->sessionTypes !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'type IN (%Ls)',
$this->sessionTypes);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -49,47 +49,47 @@ final class PhabricatorCalendarEventInviteeQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->eventPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'eventPHID IN (%Ls)',
$this->eventPHIDs);
}
if ($this->inviteePHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'inviteePHID IN (%Ls)',
$this->inviteePHIDs);
}
if ($this->inviterPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'inviterPHID IN (%Ls)',
$this->inviterPHIDs);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'status = %d',
$this->statuses);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -509,10 +509,6 @@ final class PhabricatorCalendarEventQuery
return parent::shouldGroupQueryResultRows();
}
protected function getApplicationSearchObjectPHIDColumn() {
return 'event.phid';
}
public function getQueryApplicationClass() {
return 'PhabricatorCalendarApplication';
}

View file

@ -33,14 +33,14 @@ final class PhabricatorChatLogChannelQuery
return $logs;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
if ($this->channelIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->channelIDs);
@ -48,12 +48,12 @@ final class PhabricatorChatLogChannelQuery
if ($this->channels) {
$where[] = qsprintf(
$conn_r,
$conn,
'channelName IN (%Ls)',
$this->channels);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -55,26 +55,26 @@ final class PhabricatorChatLogQuery
return $events;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
if ($this->maximumEpoch) {
if ($this->maximumEpoch !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'epoch <= %d',
$this->maximumEpoch);
}
if ($this->channelIDs) {
if ($this->channelIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'channelID IN (%Ld)',
$this->channelIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -31,26 +31,26 @@ final class PhabricatorConfigEntryQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -38,19 +38,19 @@ final class ConpherenceFulltextQuery
return $rows;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->threadPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'i.threadPHID IN (%Ls)',
$this->threadPHIDs);
}
if ($this->previousTransactionPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'i.previousTransactionPHID IN (%Ls)',
$this->previousTransactionPHIDs);
}
@ -61,12 +61,12 @@ final class ConpherenceFulltextQuery
$compiled_query = $compiler->compileQuery($tokens);
$where[] = qsprintf(
$conn_r,
$conn,
'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)',
$compiled_query);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function buildOrderByClause(AphrontDatabaseConnection $conn_r) {

View file

@ -57,7 +57,7 @@ final class ConpherenceParticipantCountQuery
}
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function buildGroupByClause(AphrontDatabaseConnection $conn) {

View file

@ -38,7 +38,7 @@ final class ConpherenceParticipantQuery extends PhabricatorOffsetPagedQuery {
$this->participantPHIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function buildOrderClause(AphrontDatabaseConnection $conn) {

View file

@ -124,46 +124,47 @@ final class PhabricatorDaemonLogQuery
return $daemons;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->notIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id NOT IN (%Ld)',
$this->notIDs);
}
if ($this->getStatusConstants()) {
$where[] = qsprintf(
$conn_r,
$conn,
'status IN (%Ls)',
$this->getStatusConstants());
}
if ($this->daemonClasses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'daemon IN (%Ls)',
$this->daemonClasses);
}
if ($this->daemonIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'daemonID IN (%Ls)',
$this->daemonIDs);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($conn, $where);
}
private function getStatusConstants() {

View file

@ -107,31 +107,31 @@ final class DifferentialInlineCommentQuery
return head($this->execute());
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
// Only find inline comments.
$where[] = qsprintf(
$conn_r,
$conn,
'changesetID IS NOT NULL');
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->revisionPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'revisionPHID IN (%Ls)',
$this->revisionPHIDs);
}
@ -139,28 +139,28 @@ final class DifferentialInlineCommentQuery
if ($this->drafts === null) {
if ($this->deletedDrafts) {
$where[] = qsprintf(
$conn_r,
$conn,
'(authorPHID = %s) OR (transactionPHID IS NOT NULL)',
$this->getViewer()->getPHID());
} else {
$where[] = qsprintf(
$conn_r,
$conn,
'(authorPHID = %s AND isDeleted = 0)
OR (transactionPHID IS NOT NULL)',
$this->getViewer()->getPHID());
}
} else if ($this->drafts) {
$where[] = qsprintf(
$conn_r,
$conn,
'(authorPHID = %s AND isDeleted = 0) AND (transactionPHID IS NULL)',
$this->getViewer()->getPHID());
} else {
$where[] = qsprintf(
$conn_r,
$conn,
'transactionPHID IS NOT NULL');
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function adjustInlinesForChangesets(

View file

@ -542,26 +542,26 @@ final class DifferentialRevisionQuery
/**
* @task internal
*/
private function buildJoinsClause($conn_r) {
private function buildJoinsClause(AphrontDatabaseConnection $conn) {
$joins = array();
if ($this->pathIDs) {
$path_table = new DifferentialAffectedPath();
$joins[] = qsprintf(
$conn_r,
$conn,
'JOIN %T p ON p.revisionID = r.id',
$path_table->getTableName());
}
if ($this->commitHashes) {
$joins[] = qsprintf(
$conn_r,
$conn,
'JOIN %T hash_rel ON hash_rel.revisionID = r.id',
ArcanistDifferentialRevisionHash::TABLE_NAME);
}
if ($this->ccs) {
$joins[] = qsprintf(
$conn_r,
$conn,
'JOIN %T e_ccs ON e_ccs.src = r.phid '.
'AND e_ccs.type = %s '.
'AND e_ccs.dst in (%Ls)',
@ -572,7 +572,7 @@ final class DifferentialRevisionQuery
if ($this->reviewers) {
$joins[] = qsprintf(
$conn_r,
$conn,
'JOIN %T reviewer ON reviewer.revisionPHID = r.phid
AND reviewer.reviewerStatus != %s
AND reviewer.reviewerPHID in (%Ls)',
@ -583,7 +583,7 @@ final class DifferentialRevisionQuery
if ($this->draftAuthors) {
$joins[] = qsprintf(
$conn_r,
$conn,
'JOIN %T has_draft ON has_draft.srcPHID = r.phid
AND has_draft.type = %s
AND has_draft.dstPHID IN (%Ls)',
@ -594,21 +594,21 @@ final class DifferentialRevisionQuery
if ($this->commitPHIDs) {
$joins[] = qsprintf(
$conn_r,
$conn,
'JOIN %T commits ON commits.revisionID = r.id',
DifferentialRevision::TABLE_COMMIT);
}
$joins[] = $this->buildJoinClauseParts($conn_r);
$joins[] = $this->buildJoinClauseParts($conn);
return $this->formatJoinClause($joins);
return $this->formatJoinClause($conn, $joins);
}
/**
* @task internal
*/
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->pathIDs) {
@ -616,32 +616,32 @@ final class DifferentialRevisionQuery
$repo_info = igroup($this->pathIDs, 'repositoryID');
foreach ($repo_info as $repository_id => $paths) {
$path_clauses[] = qsprintf(
$conn_r,
$conn,
'(p.repositoryID = %d AND p.pathID IN (%Ld))',
$repository_id,
ipull($paths, 'pathID'));
}
$path_clauses = '('.implode(' OR ', $path_clauses).')';
$path_clauses = qsprintf($conn, '%LO', $path_clauses);
$where[] = $path_clauses;
}
if ($this->authors) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.authorPHID IN (%Ls)',
$this->authors);
}
if ($this->revIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.id IN (%Ld)',
$this->revIDs);
}
if ($this->repositoryPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
@ -651,67 +651,67 @@ final class DifferentialRevisionQuery
foreach ($this->commitHashes as $info) {
list($type, $hash) = $info;
$hash_clauses[] = qsprintf(
$conn_r,
$conn,
'(hash_rel.type = %s AND hash_rel.hash = %s)',
$type,
$hash);
}
$hash_clauses = '('.implode(' OR ', $hash_clauses).')';
$hash_clauses = qsprintf($conn, '%LO', $hash_clauses);
$where[] = $hash_clauses;
}
if ($this->commitPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'commits.commitPHID IN (%Ls)',
$this->commitPHIDs);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.phid IN (%Ls)',
$this->phids);
}
if ($this->branches) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.branchName in (%Ls)',
$this->branches);
}
if ($this->updatedEpochMin !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.dateModified >= %d',
$this->updatedEpochMin);
}
if ($this->updatedEpochMax !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.dateModified <= %d',
$this->updatedEpochMax);
}
if ($this->createdEpochMin !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.dateCreated >= %d',
$this->createdEpochMin);
}
if ($this->createdEpochMax !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.dateCreated <= %d',
$this->createdEpochMax);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'r.status in (%Ls)',
$this->statuses);
}
@ -725,13 +725,14 @@ final class DifferentialRevisionQuery
DifferentialLegacyQuery::STATUS_CLOSED);
}
$where[] = qsprintf(
$conn_r,
$conn,
'r.status in (%Ls)',
$statuses);
}
$where[] = $this->buildWhereClauseParts($conn_r);
return $this->formatWhereClause($where);
$where[] = $this->buildWhereClauseParts($conn);
return $this->formatWhereClause($conn, $where);
}

View file

@ -70,7 +70,7 @@ final class DiffusionLintCountQuery extends PhabricatorQuery {
}
protected function buildCustomWhereClause(
AphrontDatabaseConnection $conn_r,
AphrontDatabaseConnection $conn,
$part) {
$where = array();
@ -79,19 +79,19 @@ final class DiffusionLintCountQuery extends PhabricatorQuery {
if ($this->codes !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'code IN (%Ls)',
$this->codes);
}
if ($this->branchIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'branchID IN (%Ld)',
$this->branchIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function processPaths() {

View file

@ -192,52 +192,52 @@ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery {
/**
* @task internal
*/
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if (isset($this->context)) {
$where[] = qsprintf(
$conn_r,
$conn,
'symbolContext = %s',
$this->context);
}
if ($this->name) {
$where[] = qsprintf(
$conn_r,
$conn,
'symbolName = %s',
$this->name);
}
if ($this->namePrefix) {
$where[] = qsprintf(
$conn_r,
$conn,
'symbolName LIKE %>',
$this->namePrefix);
}
if ($this->repositoryPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
if ($this->language) {
$where[] = qsprintf(
$conn_r,
$conn,
'symbolLanguage = %s',
$this->language);
}
if ($this->type) {
$where[] = qsprintf(
$conn_r,
$conn,
'symbolType = %s',
$this->type);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}

View file

@ -299,40 +299,40 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $atoms;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->bookPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'bookPHID IN (%Ls)',
$this->bookPHIDs);
}
if ($this->types) {
$where[] = qsprintf(
$conn_r,
$conn,
'type IN (%Ls)',
$this->types);
}
if ($this->names) {
$where[] = qsprintf(
$conn_r,
$conn,
'name IN (%Ls)',
$this->names);
}
@ -347,7 +347,7 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
}
$where[] = qsprintf(
$conn_r,
$conn,
'titleSlugHash in (%Ls)',
$hashes);
}
@ -366,46 +366,46 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
if ($contexts && $with_null) {
$where[] = qsprintf(
$conn_r,
$conn,
'context IN (%Ls) OR context IS NULL',
$contexts);
} else if ($contexts) {
$where[] = qsprintf(
$conn_r,
$conn,
'context IN (%Ls)',
$contexts);
} else if ($with_null) {
$where[] = qsprintf(
$conn_r,
$conn,
'context IS NULL');
}
}
if ($this->indexes) {
$where[] = qsprintf(
$conn_r,
$conn,
'atomIndex IN (%Ld)',
$this->indexes);
}
if ($this->isDocumentable !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'isDocumentable = %d',
(int)$this->isDocumentable);
}
if ($this->isGhost !== null) {
if ($this->isGhost) {
$where[] = qsprintf($conn_r, 'graphHash IS NULL');
$where[] = qsprintf($conn, 'graphHash IS NULL');
} else {
$where[] = qsprintf($conn_r, 'graphHash IS NOT NULL');
$where[] = qsprintf($conn, 'graphHash IS NOT NULL');
}
}
if ($this->nodeHashes) {
$where[] = qsprintf(
$conn_r,
$conn,
'nodeHash IN (%Ls)',
$this->nodeHashes);
}
@ -415,21 +415,21 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
// the column has binary collation. Eventually, this should move into
// fulltext.
$where[] = qsprintf(
$conn_r,
$conn,
'CONVERT(name USING utf8) LIKE %~',
$this->nameContains);
}
if ($this->repositoryPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
/**

View file

@ -116,54 +116,54 @@ final class DivinerBookQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $books;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if (strlen($this->nameLike)) {
$where[] = qsprintf(
$conn_r,
$conn,
'name LIKE %~',
$this->nameLike);
}
if ($this->names !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'name IN (%Ls)',
$this->names);
}
if (strlen($this->namePrefix)) {
$where[] = qsprintf(
$conn_r,
$conn,
'name LIKE %>',
$this->namePrefix);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -86,26 +86,26 @@ final class PhabricatorFileChunkQuery
return $chunks;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->chunkHandles !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'chunkHandle IN (%Ls)',
$this->chunkHandles);
}
if ($this->rangeStart !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'byteEnd > %d',
$this->rangeStart);
}
if ($this->rangeEnd !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'byteStart < %d',
$this->rangeEnd);
}
@ -113,18 +113,18 @@ final class PhabricatorFileChunkQuery
if ($this->isComplete !== null) {
if ($this->isComplete) {
$where[] = qsprintf(
$conn_r,
$conn,
'dataFilePHID IS NOT NULL');
} else {
$where[] = qsprintf(
$conn_r,
$conn,
'dataFilePHID IS NULL');
}
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -123,40 +123,40 @@ final class PhabricatorFlagQuery
return $flags;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ownerPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'flag.ownerPHID IN (%Ls)',
$this->ownerPHIDs);
}
if ($this->types) {
$where[] = qsprintf(
$conn_r,
$conn,
'flag.type IN (%Ls)',
$this->types);
}
if ($this->objectPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'flag.objectPHID IN (%Ls)',
$this->objectPHIDs);
}
if ($this->colors) {
$where[] = qsprintf(
$conn_r,
$conn,
'flag.color IN (%Ld)',
$this->colors);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -68,47 +68,47 @@ final class FundBackerQuery
return $backers;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->initiativePHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'initiativePHID IN (%Ls)',
$this->initiativePHIDs);
}
if ($this->backerPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'backerPHID IN (%Ls)',
$this->backerPHIDs);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'status IN (%Ls)',
$this->statuses);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -175,68 +175,68 @@ final class HeraldRuleQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $rules;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.phid IN (%Ls)',
$this->phids);
}
if ($this->authorPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.authorPHID IN (%Ls)',
$this->authorPHIDs);
}
if ($this->ruleTypes) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.ruleType IN (%Ls)',
$this->ruleTypes);
}
if ($this->contentTypes) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.contentType IN (%Ls)',
$this->contentTypes);
}
if ($this->disabled !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.isDisabled = %d',
(int)$this->disabled);
}
if ($this->datasourceQuery) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.name LIKE %>',
$this->datasourceQuery);
}
if ($this->triggerObjectPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'rule.triggerObjectPHID IN (%Ls)',
$this->triggerObjectPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function validateRuleAuthors(array $rules) {

View file

@ -91,33 +91,33 @@ final class HeraldTranscriptQuery
return $transcripts;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->objectPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'objectPHID in (%Ls)',
$this->objectPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -86,61 +86,61 @@ final class LegalpadDocumentSignatureQuery
return $signatures;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->documentPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'documentPHID IN (%Ls)',
$this->documentPHIDs);
}
if ($this->signerPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'signerPHID IN (%Ls)',
$this->signerPHIDs);
}
if ($this->documentVersions !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'documentVersion IN (%Ld)',
$this->documentVersions);
}
if ($this->secretKeys !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'secretKey IN (%Ls)',
$this->secretKeys);
}
if ($this->nameContains !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'signerName LIKE %~',
$this->nameContains);
}
if ($this->emailContains !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'signerEmail LIKE %~',
$this->emailContains);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -37,33 +37,33 @@ final class PhabricatorOAuthServerClientQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->creatorPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'creatorPHID IN (%Ls)',
$this->creatorPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -37,33 +37,33 @@ final class PhluxVariableQuery
return $table->loadAllFromArray($rows);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->keys !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'variableKey IN (%Ls)',
$this->keys);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function getDefaultOrderVector() {

View file

@ -61,40 +61,40 @@ final class PholioImageQuery
return $images;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->mockIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'mockID IN (%Ld)',
$this->mockIDs);
}
if ($this->obsolete !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'isObsolete = %d',
$this->obsolete);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function willFilterPage(array $images) {

View file

@ -99,7 +99,7 @@ final class PhortuneAccountQuery
$this->memberPHIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function buildJoinClause(AphrontDatabaseConnection $conn) {

View file

@ -213,7 +213,7 @@ final class PhortuneCartQuery
}
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -134,7 +134,7 @@ final class PhortuneChargeQuery
$this->statuses);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -114,7 +114,7 @@ final class PhortuneMerchantQuery
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function buildJoinClause(AphrontDatabaseConnection $conn) {

View file

@ -85,7 +85,7 @@ final class PhortunePaymentProviderConfigQuery
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -105,12 +105,12 @@ final class PhortuneProductQuery
PhabricatorHash::digestForIndex($ref));
}
}
$where[] = implode(' OR ', $sql);
$where[] = qsprintf($conn, '%LO', $sql);
}
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -100,7 +100,7 @@ final class PhortunePurchaseQuery
$this->cartPHIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -182,7 +182,7 @@ final class PhortuneSubscriptionQuery
$this->statuses);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -55,47 +55,47 @@ final class PhragmentFragmentQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->paths) {
$where[] = qsprintf(
$conn_r,
$conn,
'path IN (%Ls)',
$this->paths);
}
if ($this->leadingPath) {
$where[] = qsprintf(
$conn_r,
$conn,
'path LIKE %>',
$this->leadingPath);
}
if ($this->depths) {
$where[] = qsprintf(
$conn_r,
$conn,
'depth IN (%Ld)',
$this->depths);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function didFilterPage(array $page) {

View file

@ -49,47 +49,47 @@ final class PhragmentFragmentVersionQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->fragmentPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'fragmentPHID IN (%Ls)',
$this->fragmentPHIDs);
}
if ($this->sequences) {
$where[] = qsprintf(
$conn_r,
$conn,
'sequence IN (%Ld)',
$this->sequences);
}
if ($this->sequenceBefore !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'sequence < %d',
$this->sequenceBefore);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function willFilterPage(array $page) {

View file

@ -55,40 +55,40 @@ final class PhragmentSnapshotChildQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->snapshotPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'snapshotPHID IN (%Ls)',
$this->snapshotPHIDs);
}
if ($this->fragmentPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'fragmentPHID IN (%Ls)',
$this->fragmentPHIDs);
}
if ($this->fragmentVersionPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'fragmentVersionPHID IN (%Ls)',
$this->fragmentVersionPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function willFilterPage(array $page) {

View file

@ -43,40 +43,40 @@ final class PhragmentSnapshotQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids) {
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->primaryFragmentPHIDs) {
if ($this->primaryFragmentPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'primaryFragmentPHID IN (%Ls)',
$this->primaryFragmentPHIDs);
}
if ($this->names) {
if ($this->names !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'name IN (%Ls)',
$this->names);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function willFilterPage(array $page) {

View file

@ -116,7 +116,7 @@ final class PhrequentUserTimeQuery
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getOrderableColumns() {

View file

@ -103,26 +103,26 @@ final class ReleephBranchQuery
return $branches;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->productIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'releephProjectID IN (%Ld)',
$this->productIDs);
}
@ -133,16 +133,16 @@ final class ReleephBranchQuery
break;
case self::STATUS_OPEN:
$where[] = qsprintf(
$conn_r,
$conn,
'isActive = 1');
break;
default:
throw new Exception(pht("Unknown status constant '%s'!", $status));
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -83,40 +83,40 @@ final class ReleephProductQuery
return $projects;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->active !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'isActive = %d',
(int)$this->active);
}
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ls)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getOrderableColumns() {

View file

@ -147,54 +147,54 @@ final class ReleephRequestQuery
return $requests;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->branchIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'branchID IN (%Ld)',
$this->branchIDs);
}
if ($this->requestedCommitPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'requestCommitPHID IN (%Ls)',
$this->requestedCommitPHIDs);
}
if ($this->requestorPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'requestUserPHID IN (%Ls)',
$this->requestorPHIDs);
}
if ($this->requestedObjectPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'requestedObjectPHID IN (%Ls)',
$this->requestedObjectPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function getKeepStatusConstants() {

View file

@ -37,33 +37,33 @@ final class PhabricatorSavedQueryQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->engineClassNames !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'engineClassName IN (%Ls)',
$this->engineClassNames);
}
if ($this->queryKeys !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'queryKey IN (%Ls)',
$this->queryKeys);
}
$where[] = $this->buildPagingClause($conn_r);
$where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {

View file

@ -24,17 +24,17 @@ final class PhabricatorTokenCountQuery
return ipull($rows, 'tokenCount', 'objectPHID');
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->objectPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'objectPHID IN (%Ls)',
$this->objectPHIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
}

View file

@ -57,46 +57,48 @@ abstract class PhabricatorApplicationTransactionCommentQuery
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
return $this->formatWhereClause($this->buildWhereClauseComponents($conn_r));
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
return $this->formatWhereClause(
$conn,
$this->buildWhereClauseComponents($conn));
}
protected function buildWhereClauseComponents(
AphrontDatabaseConnection $conn_r) {
AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.phid IN (%Ls)',
$this->phids);
}
if ($this->authorPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.authorPHID IN (%Ls)',
$this->authorPHIDs);
}
if ($this->transactionPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.transactionPHID IN (%Ls)',
$this->transactionPHIDs);
}
if ($this->isDeleted !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.isDeleted = %d',
(int)$this->isDeleted);
}
@ -104,11 +106,11 @@ abstract class PhabricatorApplicationTransactionCommentQuery
if ($this->hasTransaction !== null) {
if ($this->hasTransaction) {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.transactionPHID IS NOT NULL');
} else {
$where[] = qsprintf(
$conn_r,
$conn,
'xcomment.transactionPHID IS NULL');
}
}

View file

@ -209,39 +209,47 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery {
}
protected function buildCustomWhereClause(
AphrontDatabaseConnection $conn_w,
AphrontDatabaseConnection $conn,
$phase) {
$where = array();
switch ($phase) {
case self::PHASE_LEASED:
$where[] = 'leaseOwner IS NOT NULL';
$where[] = 'leaseExpires >= UNIX_TIMESTAMP()';
$where[] = qsprintf(
$conn,
'leaseOwner IS NOT NULL');
$where[] = qsprintf(
$conn,
'leaseExpires >= UNIX_TIMESTAMP()');
break;
case self::PHASE_UNLEASED:
$where[] = 'leaseOwner IS NULL';
$where[] = qsprintf(
$conn,
'leaseOwner IS NULL');
break;
case self::PHASE_EXPIRED:
$where[] = 'leaseExpires < UNIX_TIMESTAMP()';
$where[] = qsprintf(
$conn,
'leaseExpires < UNIX_TIMESTAMP()');
break;
default:
throw new Exception(pht("Unknown phase '%s'!", $phase));
}
if ($this->ids !== null) {
$where[] = qsprintf($conn_w, 'id IN (%Ld)', $this->ids);
$where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf($conn_w, 'objectPHID IN (%Ls)', $this->objectPHIDs);
$where[] = qsprintf($conn, 'objectPHID IN (%Ls)', $this->objectPHIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function buildUpdateWhereClause(
AphrontDatabaseConnection $conn_w,
AphrontDatabaseConnection $conn,
$phase,
array $rows) {
@ -257,25 +265,25 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery {
'Trying to lease tasks selected in the leased phase! This is '.
'intended to be impossible.'));
case self::PHASE_UNLEASED:
$where[] = qsprintf($conn_w, 'leaseOwner IS NULL');
$where[] = qsprintf($conn_w, 'id IN (%Ld)', ipull($rows, 'id'));
$where[] = qsprintf($conn, 'leaseOwner IS NULL');
$where[] = qsprintf($conn, 'id IN (%Ld)', ipull($rows, 'id'));
break;
case self::PHASE_EXPIRED:
$in = array();
foreach ($rows as $row) {
$in[] = qsprintf(
$conn_w,
$conn,
'(id = %d AND leaseOwner = %s)',
$row['id'],
$row['leaseOwner']);
}
$where[] = qsprintf($conn_w, '(%Q)', implode(' OR ', $in));
$where[] = qsprintf($conn, '%LO', $in);
break;
default:
throw new Exception(pht('Unknown phase "%s"!', $phase));
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function buildOrderClause(AphrontDatabaseConnection $conn_w, $phase) {

View file

@ -48,59 +48,59 @@ abstract class PhabricatorWorkerTaskQuery
return $this;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id in (%Ld)',
$this->ids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'objectPHID IN (%Ls)',
$this->objectPHIDs);
}
if ($this->dateModifiedSince !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'dateModified > %d',
$this->dateModifiedSince);
}
if ($this->dateCreatedBefore !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'dateCreated < %d',
$this->dateCreatedBefore);
}
if ($this->classNames !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'taskClass IN (%Ls)',
$this->classNames);
}
if ($this->minFailureCount !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'failureCount >= %d',
$this->minFailureCount);
}
if ($this->maxFailureCount !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'failureCount <= %d',
$this->maxFailureCount);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
protected function buildOrderClause(AphrontDatabaseConnection $conn_r) {

View file

@ -160,52 +160,52 @@ final class PhabricatorWorkerTriggerQuery
return implode(' ', $joins);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
't.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
't.phid IN (%Ls)',
$this->phids);
}
if ($this->versionMin !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
't.triggerVersion >= %d',
$this->versionMin);
}
if ($this->versionMax !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
't.triggerVersion <= %d',
$this->versionMax);
}
if ($this->nextEpochMin !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'e.nextEventEpoch >= %d',
$this->nextEpochMin);
}
if ($this->nextEpochMax !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'e.nextEventEpoch <= %d',
$this->nextEpochMax);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
private function buildOrderClause(AphrontDatabaseConnection $conn_r) {

View file

@ -290,19 +290,19 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
/**
* @task internal
*/
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->sourcePHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'edge.src IN (%Ls)',
$this->sourcePHIDs);
}
if ($this->edgeTypes) {
$where[] = qsprintf(
$conn_r,
$conn,
'edge.type IN (%Ls)',
$this->edgeTypes);
}
@ -310,12 +310,12 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
if ($this->destPHIDs) {
// potentially complain if $this->edgeType was not set
$where[] = qsprintf(
$conn_r,
$conn,
'edge.dst IN (%Ls)',
$this->destPHIDs);
}
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}

View file

@ -27,15 +27,15 @@ abstract class PhabricatorOffsetPagedQuery extends PhabricatorQuery {
return $this->limit;
}
protected function buildLimitClause(AphrontDatabaseConnection $conn_r) {
protected function buildLimitClause(AphrontDatabaseConnection $conn) {
if ($this->limit && $this->offset) {
return qsprintf($conn_r, 'LIMIT %d, %d', $this->offset, $this->limit);
return qsprintf($conn, 'LIMIT %d, %d', $this->offset, $this->limit);
} else if ($this->limit) {
return qsprintf($conn_r, 'LIMIT %d', $this->limit);
return qsprintf($conn, 'LIMIT %d', $this->limit);
} else if ($this->offset) {
return qsprintf($conn_r, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX);
return qsprintf($conn, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX);
} else {
return '';
return qsprintf($conn, '');
}
}

View file

@ -15,28 +15,19 @@ abstract class PhabricatorQuery extends Phobject {
/**
* @task format
*/
protected function formatWhereClause(array $parts) {
protected function formatWhereClause(
AphrontDatabaseConnection $conn,
array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return '';
return qsprintf($conn, '');
}
return 'WHERE '.$this->formatWhereSubclause($parts);
return qsprintf($conn, 'WHERE %LA', $parts);
}
/**
* @task format
*/
protected function formatWhereSubclause(array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return null;
}
return '('.implode(') AND (', $parts).')';
}
/**
* @task format
@ -57,39 +48,32 @@ abstract class PhabricatorQuery extends Phobject {
/**
* @task format
*/
protected function formatJoinClause(array $parts) {
protected function formatJoinClause(
AphrontDatabaseConnection $conn,
array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return '';
return qsprintf($conn, '');
}
return implode(' ', $parts);
return qsprintf($conn, '%LJ', $parts);
}
/**
* @task format
*/
protected function formatHavingClause(array $parts) {
protected function formatHavingClause(
AphrontDatabaseConnection $conn,
array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return '';
return qsprintf($conn, '');
}
return 'HAVING '.$this->formatHavingSubclause($parts);
}
/**
* @task format
*/
protected function formatHavingSubclause(array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return null;
}
return '('.implode(') AND (', $parts).')';
return qsprintf($conn, 'HAVING %LA', $parts);
}

View file

@ -195,15 +195,15 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
}
final protected function buildLimitClause(AphrontDatabaseConnection $conn_r) {
final protected function buildLimitClause(AphrontDatabaseConnection $conn) {
if ($this->shouldLimitResults()) {
$limit = $this->getRawResultLimit();
if ($limit) {
return qsprintf($conn_r, 'LIMIT %d', $limit);
return qsprintf($conn, 'LIMIT %d', $limit);
}
}
return '';
return qsprintf($conn, '');
}
protected function shouldLimitResults() {
@ -306,7 +306,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/
protected function buildJoinClause(AphrontDatabaseConnection $conn) {
$joins = $this->buildJoinClauseParts($conn);
return $this->formatJoinClause($joins);
return $this->formatJoinClause($conn, $joins);
}
@ -328,7 +328,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = $this->buildWhereClauseParts($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
}
@ -352,7 +352,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/
protected function buildHavingClause(AphrontDatabaseConnection $conn) {
$having = $this->buildHavingClauseParts($conn);
return $this->formatHavingClause($having);
return $this->formatHavingClause($conn, $having);
}
@ -371,13 +371,13 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/
protected function buildGroupClause(AphrontDatabaseConnection $conn) {
if (!$this->shouldGroupQueryResultRows()) {
return '';
return qsprintf($conn, '');
}
return qsprintf(
$conn,
'GROUP BY %Q',
$this->getApplicationSearchObjectPHIDColumn());
$this->getApplicationSearchObjectPHIDColumn($conn));
}
@ -1134,7 +1134,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
}
return qsprintf($conn, 'ORDER BY %Q', implode(', ', $sql));
return qsprintf($conn, 'ORDER BY %LQ', $sql);
}
@ -1244,17 +1244,18 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
* See @{method:getPrimaryTableAlias} if the column needs to be qualified with
* a table alias.
*
* @return string Column name.
* @param AphrontDatabaseConnection Connection executing queries.
* @return PhutilQueryString Column name.
* @task appsearch
*/
protected function getApplicationSearchObjectPHIDColumn() {
if ($this->getPrimaryTableAlias()) {
$prefix = $this->getPrimaryTableAlias().'.';
} else {
$prefix = '';
}
protected function getApplicationSearchObjectPHIDColumn(
AphrontDatabaseConnection $conn) {
return $prefix.'phid';
if ($this->getPrimaryTableAlias()) {
return qsprintf($conn, '%T.phid', $this->getPrimaryTableAlias());
} else {
return qsprintf($conn, 'phid');
}
}
@ -1308,15 +1309,15 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
* @task appsearch
*/
protected function buildApplicationSearchGroupClause(
AphrontDatabaseConnection $conn_r) {
AphrontDatabaseConnection $conn) {
if ($this->getApplicationSearchMayJoinMultipleRows()) {
return qsprintf(
$conn_r,
$conn,
'GROUP BY %Q',
$this->getApplicationSearchObjectPHIDColumn());
} else {
return '';
return qsprintf($conn, '');
}
}
@ -1410,7 +1411,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
}
$phid_column = $this->getApplicationSearchObjectPHIDColumn();
$phid_column = $this->getApplicationSearchObjectPHIDColumn($conn);
$orderable = $this->getOrderableColumns();
$vector = $this->getOrderVector();
@ -2373,7 +2374,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/
public function buildEdgeLogicJoinClause(AphrontDatabaseConnection $conn) {
$edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE;
$phid_column = $this->getApplicationSearchObjectPHIDColumn();
$phid_column = $this->getApplicationSearchObjectPHIDColumn($conn);
$joins = array();
foreach ($this->edgeLogicConstraints as $type => $constraints) {
@ -2531,9 +2532,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
if ($full && $null) {
$full = $this->formatWhereSubclause($full);
$null = $this->formatWhereSubclause($null);
$where[] = qsprintf($conn, '(%Q OR %Q)', $full, $null);
$where[] = qsprintf($conn, '(%LA OR %LA)', $full, $null);
} else if ($full) {
foreach ($full as $condition) {
$where[] = $condition;

View file

@ -517,13 +517,14 @@ abstract class LiskDAO extends Phobject
protected function loadRawDataWhere($pattern /* , $args... */) {
$connection = $this->establishConnection('r');
$conn = $this->establishConnection('r');
$lock_clause = '';
if ($connection->isReadLocking()) {
$lock_clause = 'FOR UPDATE';
} else if ($connection->isWriteLocking()) {
$lock_clause = 'LOCK IN SHARE MODE';
if ($conn->isReadLocking()) {
$lock_clause = qsprintf($conn, 'FOR UPDATE');
} else if ($conn->isWriteLocking()) {
$lock_clause = qsprintf($conn, 'LOCK IN SHARE MODE');
} else {
$lock_clause = qsprintf($conn, '');
}
$args = func_get_args();
@ -534,9 +535,7 @@ abstract class LiskDAO extends Phobject
array_push($args, $lock_clause);
array_unshift($args, $pattern);
return call_user_func_array(
array($connection, 'queryData'),
$args);
return call_user_func_array(array($conn, 'queryData'), $args);
}