Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F727010
D431.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jan 6, 5:04 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Tue, Jan 7, 5:04 AM (2 d, 22 h ago)
Engine
blob
Format
Raw Data
Handle
537079
Attached To
D431: INP-1826 - Convert search/custom having filters into a where filters in grids
D431.diff
View Options
Index: branches/5.2.x/core/kernel/db/dblist.php
===================================================================
--- branches/5.2.x/core/kernel/db/dblist.php
+++ branches/5.2.x/core/kernel/db/dblist.php
@@ -725,6 +725,10 @@
*/
public function extractCalculatedFields($clause, $aggregated = 1, $replace_table = false)
{
+ if ( !$clause ) {
+ return '';
+ }
+
$fields = $this->getCalculatedFields($aggregated);
if ( is_array($fields) && count($fields) > 0 ) {
@@ -759,23 +763,18 @@
if (!$system_filters_only) {
$where->addFilter('view_where', $this->WhereFilter[self::FLT_VIEW] );
- $search_w = $this->WhereFilter[self::FLT_SEARCH]->getSQL();
- if ($search_w || $for_counting) { // move search_having to search_where in case search_where isset or we are counting
- $search_h = $this->extractCalculatedFields( $this->HavingFilter[self::FLT_SEARCH]->getSQL() );
- $search_w = ($search_w && $search_h) ? $search_w.' OR '.$search_h : $search_w.$search_h;
- $where->addFilter('search_where', $search_w );
- }
+ // Handle general grid search filter. Append transformed having clause into where clause.
+ $search_w = $this->WhereFilter[self::FLT_SEARCH]->getSQL();
+ $search_h = $this->extractCalculatedFields($this->HavingFilter[self::FLT_SEARCH]->getSQL());
+ $search_w = ($search_w && $search_h) ? $search_w . ' OR ' . $search_h : $search_w . $search_h;
+ $where->addFilter('search_where', $search_w);
- // CUSTOM
+ // Handle custom per-column grid filters. Append transformed having clause into where clause.
$search_w = $this->WhereFilter[self::FLT_CUSTOM]->getSQL();
-
- if ($search_w || $for_counting) { // move search_having to search_where in case search_where isset or we are counting
- $search_h = $this->extractCalculatedFields( $this->HavingFilter[self::FLT_CUSTOM]->getSQL() );
- $search_w = ($search_w && $search_h) ? $search_w.' AND '.$search_h : $search_w.$search_h;
- $where->addFilter('custom_where', $search_w );
- }
- // CUSTOM
+ $search_h = $this->extractCalculatedFields($this->HavingFilter[self::FLT_CUSTOM]->getSQL());
+ $search_w = ($search_w && $search_h) ? $search_w . ' AND ' . $search_h : $search_w . $search_h;
+ $where->addFilter('custom_where', $search_w);
}
if( $for_counting ) // add system_having and view_having to where
@@ -821,12 +820,8 @@
}
if (!$system_filters_only) {
+ // Don't add search/custom having filters here, because they're added to the where clause.
$having->addFilter('view_having', $this->HavingFilter[kDBList::FLT_VIEW] );
- $having->addFilter('custom_having', $this->HavingFilter[kDBList::FLT_CUSTOM] );
- $search_w = $this->WhereFilter[kDBList::FLT_SEARCH]->getSQL();
- if (!$search_w) {
- $having->addFilter('search_having', $this->HavingFilter[kDBList::FLT_SEARCH] );
- }
}
return $having->getSQL();
Event Timeline
Log In to Comment