mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-01 15:08:14 +02:00
Skip Ferret fulltext columns in "ORDER BY" if there's no fulltext query
Summary: Ref T13091. If you "Order By: Relevance" but don't actually specify a query, we currently raise a bare exception. This operation is sort of silly/pointless, but it seems like it's probably best to just return the results for the other constraints in the fallback order (usually, by ID). Alternatively, we could raise a non-bare exception here ("You need to provide a fulltext query to order by relevance.") Test Plan: Queried tasks by relevance with no actual query text. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13091 Differential Revision: https://secure.phabricator.com/D20296
This commit is contained in:
parent
3940c8e1f4
commit
a8ba8217d8
1 changed files with 31 additions and 2 deletions
|
@ -538,7 +538,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
*/
|
*/
|
||||||
protected function buildPagingClause(AphrontDatabaseConnection $conn) {
|
protected function buildPagingClause(AphrontDatabaseConnection $conn) {
|
||||||
$orderable = $this->getOrderableColumns();
|
$orderable = $this->getOrderableColumns();
|
||||||
$vector = $this->getOrderVector();
|
$vector = $this->getQueryableOrderVector();
|
||||||
|
|
||||||
// If we don't have a cursor object yet, it means we're trying to load
|
// If we don't have a cursor object yet, it means we're trying to load
|
||||||
// the first result page. We may need to build a cursor object from the
|
// the first result page. We may need to build a cursor object from the
|
||||||
|
@ -1099,16 +1099,19 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
'table' => null,
|
'table' => null,
|
||||||
'column' => '_ft_rank',
|
'column' => '_ft_rank',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
|
'requires-ferret' => true,
|
||||||
);
|
);
|
||||||
$columns['fulltext-created'] = array(
|
$columns['fulltext-created'] = array(
|
||||||
'table' => 'ft_doc',
|
'table' => 'ft_doc',
|
||||||
'column' => 'epochCreated',
|
'column' => 'epochCreated',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
|
'requires-ferret' => true,
|
||||||
);
|
);
|
||||||
$columns['fulltext-modified'] = array(
|
$columns['fulltext-modified'] = array(
|
||||||
'table' => 'ft_doc',
|
'table' => 'ft_doc',
|
||||||
'column' => 'epochModified',
|
'column' => 'epochModified',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
|
'requires-ferret' => true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1126,11 +1129,12 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
$for_union = false) {
|
$for_union = false) {
|
||||||
|
|
||||||
$orderable = $this->getOrderableColumns();
|
$orderable = $this->getOrderableColumns();
|
||||||
$vector = $this->getOrderVector();
|
$vector = $this->getQueryableOrderVector();
|
||||||
|
|
||||||
$parts = array();
|
$parts = array();
|
||||||
foreach ($vector as $order) {
|
foreach ($vector as $order) {
|
||||||
$part = $orderable[$order->getOrderKey()];
|
$part = $orderable[$order->getOrderKey()];
|
||||||
|
|
||||||
if ($order->getIsReversed()) {
|
if ($order->getIsReversed()) {
|
||||||
$part['reverse'] = !idx($part, 'reverse', false);
|
$part['reverse'] = !idx($part, 'reverse', false);
|
||||||
}
|
}
|
||||||
|
@ -1140,6 +1144,31 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
return $this->formatOrderClause($conn, $parts, $for_union);
|
return $this->formatOrderClause($conn, $parts, $for_union);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task order
|
||||||
|
*/
|
||||||
|
private function getQueryableOrderVector() {
|
||||||
|
$vector = $this->getOrderVector();
|
||||||
|
$orderable = $this->getOrderableColumns();
|
||||||
|
|
||||||
|
$keep = array();
|
||||||
|
foreach ($vector as $order) {
|
||||||
|
$column = $orderable[$order->getOrderKey()];
|
||||||
|
|
||||||
|
// If this is a Ferret fulltext column but the query doesn't actually
|
||||||
|
// have a fulltext query, we'll skip most of the Ferret stuff and won't
|
||||||
|
// actually have the columns in the result set. Just skip them.
|
||||||
|
if (!empty($column['requires-ferret'])) {
|
||||||
|
if (!$this->getFerretTokens()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$keep[] = $order->getAsScalar();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhabricatorQueryOrderVector::newFromVector($keep);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @task order
|
* @task order
|
||||||
|
|
Loading…
Add table
Reference in a new issue