/**
  * @dataProvider getBogusFilters
  * @group Core
  */
 public function testBogusFiltersExpectExceptionThrown($bogus)
 {
     try {
         $segment = new SegmentExpression($bogus);
         $segment->parseSubExpressions();
         $segment->getSql();
     } catch (\Exception $e) {
         return;
     }
     $this->fail('Expected exception not raised for:' . var_export($segment->getSql(), true));
 }
Пример #2
0
 public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit)
 {
     if (!is_array($from)) {
         $from = array($from);
     }
     $fromInitially = $from;
     if (!$segmentExpression->isEmpty()) {
         $segmentExpression->parseSubExpressionsIntoSqlExpressions($from);
         $segmentSql = $segmentExpression->getSql();
         $where = $this->getWhereMatchBoth($where, $segmentSql['where']);
         $bind = array_merge($bind, $segmentSql['bind']);
     }
     $joins = $this->generateJoinsString($from);
     $joinWithSubSelect = $joins['joinWithSubSelect'];
     $from = $joins['sql'];
     // hack for https://github.com/piwik/piwik/issues/9194#issuecomment-164321612
     $useSpecialConversionGroupBy = !empty($segmentSql) && strpos($groupBy, 'log_conversion.idgoal') !== false && $fromInitially == array('log_conversion') && strpos($from, 'log_link_visit_action') !== false;
     if ($useSpecialConversionGroupBy) {
         $innerGroupBy = "CONCAT(log_conversion.idvisit, '_' , log_conversion.idgoal, '_', log_conversion.buster)";
         $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit, $innerGroupBy);
     } elseif ($joinWithSubSelect) {
         $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     } else {
         $sql = $this->buildSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     }
     return array('sql' => $sql, 'bind' => $bind);
 }
Пример #3
0
 public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit)
 {
     if (!is_array($from)) {
         $from = array($from);
     }
     if (!$segmentExpression->isEmpty()) {
         $segmentExpression->parseSubExpressionsIntoSqlExpressions($from);
         $segmentSql = $segmentExpression->getSql();
         $where = $this->getWhereMatchBoth($where, $segmentSql['where']);
         $bind = array_merge($bind, $segmentSql['bind']);
     }
     $joins = $this->generateJoinsString($from);
     $joinWithSubSelect = $joins['joinWithSubSelect'];
     $from = $joins['sql'];
     if ($joinWithSubSelect) {
         $sql = $this->buildWrappedSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     } else {
         $sql = $this->buildSelectQuery($select, $from, $where, $groupBy, $orderBy, $limit);
     }
     return array('sql' => $sql, 'bind' => $bind);
 }