diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-09-18 03:53:06 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-09-18 03:53:06 +0300 |
commit | 71f491aca60034396120fe47c1b3db0fa9fd894e (patch) | |
tree | 8662240db13ee899e935ed575db11ea4c4bb5394 | |
parent | d1260617f4dea3d8366f2ca284e79affca46c8a0 (diff) |
Provide possibility to force not using a subquery (#14786)
* Provide possibility to force not using a subquery
* Update LogAggregator.php
* Update LogQueryBuilder.php
* Update LogAggregator.php
-rw-r--r-- | core/DataAccess/LogAggregator.php | 2 | ||||
-rw-r--r-- | core/DataAccess/LogQueryBuilder.php | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php index c8478c5cdc..9ac71efc87 100644 --- a/core/DataAccess/LogAggregator.php +++ b/core/DataAccess/LogAggregator.php @@ -324,7 +324,7 @@ class LogAggregator $logQueryBuilder = StaticContainer::get('Piwik\DataAccess\LogQueryBuilder'); $forceGroupByBackup = $logQueryBuilder->getForcedInnerGroupBySubselect(); - $logQueryBuilder->forceInnerGroupBySubselect(''); + $logQueryBuilder->forceInnerGroupBySubselect(LogQueryBuilder::FORCE_INNER_GROUP_BY_NO_SUBSELECT); $segmentSql = $this->segment->getSelectQuery('distinct log_visit.idvisit as idvisit', 'log_visit', $segmentWhere, $segmentBind, 'log_visit.idvisit ASC'); $logQueryBuilder->forceInnerGroupBySubselect($forceGroupByBackup); diff --git a/core/DataAccess/LogQueryBuilder.php b/core/DataAccess/LogQueryBuilder.php index 32dc6a384a..9e6e57653b 100644 --- a/core/DataAccess/LogQueryBuilder.php +++ b/core/DataAccess/LogQueryBuilder.php @@ -17,6 +17,8 @@ use Piwik\Segment\SegmentExpression; class LogQueryBuilder { + const FORCE_INNER_GROUP_BY_NO_SUBSELECT = '__##nosubquery##__'; + /** * @var LogTablesProvider */ @@ -76,7 +78,11 @@ class LogQueryBuilder && strpos($from, 'log_link_visit_action') !== false); if (!empty($this->forcedInnerGroupBy)) { - $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limitAndOffset, $tables, $this->forcedInnerGroupBy); + if ($this->forcedInnerGroupBy === self::FORCE_INNER_GROUP_BY_NO_SUBSELECT) { + $sql = $this->buildSelectQuery($select, $from, $where, $groupBy, $orderBy, $limitAndOffset); + } else { + $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limitAndOffset, $tables, $this->forcedInnerGroupBy); + } } elseif ($useSpecialConversionGroupBy) { $innerGroupBy = "CONCAT(log_conversion.idvisit, '_' , log_conversion.idgoal, '_', log_conversion.buster)"; $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limitAndOffset, $tables, $innerGroupBy); |