public function testIsDistinct()
 {
     $adapter = new RedBeanModelSelectQueryAdapter();
     $this->assertFalse($adapter->isDistinct());
     $adapter = new RedBeanModelSelectQueryAdapter(true);
     $this->assertTrue($adapter->isDistinct());
 }
 /**
  * Resolve sql query adapter for count query.
  * @param RedBeanModelSelectQueryAdapter $selectQueryAdapter
  * @return RedBeanModelSelectQueryAdapter
  * @throws NotSupportedException
  */
 protected function resolveSqlQueryAdapterForCount(RedBeanModelSelectQueryAdapter $selectQueryAdapter)
 {
     if ($selectQueryAdapter->isDistinct()) {
         throw new NotSupportedException();
     }
     return $this->makeSelectQueryAdapter($selectQueryAdapter->isDistinct());
 }
예제 #3
0
 /**
  * @param $selectQueryAdapter
  * @param bool $selectJustCount
  * @return string
  */
 protected function makeSqlQueryForFetchingTotalItemCount($selectQueryAdapter, $selectJustCount = false)
 {
     $moduleClassName = $this->report->getModuleClassName();
     $modelClassName = $moduleClassName::getPrimaryModelName();
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter($modelClassName);
     $this->makeDisplayAttributes($joinTablesAdapter, $selectQueryAdapter);
     $where = $this->makeFiltersContent($joinTablesAdapter);
     $orderBy = $this->makeOrderBysContent($joinTablesAdapter);
     $groupBy = $this->makeGroupBysContentForCount($joinTablesAdapter);
     //Make a fresh selectQueryAdapter that only has a count clause
     if ($selectJustCount) {
         //Currently this is always expected as false. If it is true, we need to add support for SpecificCountClauses
         //so we know which table/id the count is on.
         if ($selectQueryAdapter->isDistinct()) {
             throw new NotSupportedException();
         }
         $selectQueryAdapter = new RedBeanModelSelectQueryAdapter($selectQueryAdapter->isDistinct());
         $selectQueryAdapter->addNonSpecificCountClause();
     }
     return SQLQueryUtil::makeQuery($modelClassName::getTableName($modelClassName), $selectQueryAdapter, $joinTablesAdapter, null, null, $where, $orderBy, $groupBy);
 }