original_string: protected function _buildSubquery($query)
      {
          $filterQuery = clone $query;
          $filterQuery->disableAutoFields();
          $filterQuery->mapReduce(null, null, true);
          $filterQuery->formatResults(null, true);
          $filterQuery->contain([], true);
          $filterQuery->setValueBinder(new ValueBinder());
  
          if (!$filterQuery->clause('limit')) {
              $filterQuery->limit(null);
              $filterQuery->order([], true);
              $filterQuery->offset(null);
          }
  
          $fields = $this->_subqueryFields($query);
          $filterQuery->select($fields['select'], true)->group($fields['group']);
  
          return $filterQuery;
      }
code: protected function _buildSubquery($query)
      {
          $filterQuery = clone $query;
          $filterQuery->disableAutoFields();
          $filterQuery->mapReduce(null, null, true);
          $filterQuery->formatResults(null, true);
          $filterQuery->contain([], true);
          $filterQuery->setValueBinder(new ValueBinder());
  
          if (!$filterQuery->clause('limit')) {
              $filterQuery->limit(null);
              $filterQuery->order([], true);
              $filterQuery->offset(null);
          }
  
          $fields = $this->_subqueryFields($query);
          $filterQuery->select($fields['select'], true)->group($fields['group']);
  
          return $filterQuery;
      }
code_tokens: protected function _buildSubquery ( $ query ) { $ filterQuery = clone $ query ; $ filterQuery -> disableAutoFields ( ) ; $ filterQuery -> mapReduce ( null , null , true ) ; $ filterQuery -> formatResults ( null , true ) ; $ filterQuery -> contain ( [ ] , true ) ; $ filterQuery -> setValueBinder ( new ValueBinder ( ) ) ; if ( ! $ filterQuery -> clause ( 'limit' ) ) { $ filterQuery -> limit ( null ) ; $ filterQuery -> order ( [ ] , true ) ; $ filterQuery -> offset ( null ) ; } $ fields = $ this -> _subqueryFields ( $ query ) ; $ filterQuery -> select ( $ fields [ 'select' ] , true ) -> group ( $ fields [ 'group' ] ) ; return $ filterQuery ; }
docstring: Builds a query to be used as a condition for filtering records in the
  target table, it is constructed by cloning the original query that was used
  to load records in the source table.
  
  @param \Cake\ORM\Query $query the original query used to load source records
  @return \Cake\ORM\Query
docstring_tokens: Builds a query to be used as a condition for filtering records in the target table it is constructed by cloning the original query that was used to load records in the source table .