original_string: protected function _buildSelectPart($parts, $query, $generator)
      {
          $driver = $query->getConnection()->getDriver();
          $select = 'SELECT%s %s%s';
          if ($this->_orderedUnion && $query->clause('union')) {
              $select = '(SELECT%s %s%s';
          }
          $distinct = $query->clause('distinct');
          $modifiers = $this->_buildModifierPart($query->clause('modifier'), $query, $generator);
  
          $normalized = [];
          $parts = $this->_stringifyExpressions($parts, $generator);
          foreach ($parts as $k => $p) {
              if (!is_numeric($k)) {
                  $p = $p . ' AS ' . $driver->quoteIdentifier($k);
              }
              $normalized[] = $p;
          }
  
          if ($distinct === true) {
              $distinct = 'DISTINCT ';
          }
  
          if (is_array($distinct)) {
              $distinct = $this->_stringifyExpressions($distinct, $generator);
              $distinct = sprintf('DISTINCT ON (%s) ', implode(', ', $distinct));
          }
  
          return sprintf($select, $modifiers, $distinct, implode(', ', $normalized));
      }
code: protected function _buildSelectPart($parts, $query, $generator)
      {
          $driver = $query->getConnection()->getDriver();
          $select = 'SELECT%s %s%s';
          if ($this->_orderedUnion && $query->clause('union')) {
              $select = '(SELECT%s %s%s';
          }
          $distinct = $query->clause('distinct');
          $modifiers = $this->_buildModifierPart($query->clause('modifier'), $query, $generator);
  
          $normalized = [];
          $parts = $this->_stringifyExpressions($parts, $generator);
          foreach ($parts as $k => $p) {
              if (!is_numeric($k)) {
                  $p = $p . ' AS ' . $driver->quoteIdentifier($k);
              }
              $normalized[] = $p;
          }
  
          if ($distinct === true) {
              $distinct = 'DISTINCT ';
          }
  
          if (is_array($distinct)) {
              $distinct = $this->_stringifyExpressions($distinct, $generator);
              $distinct = sprintf('DISTINCT ON (%s) ', implode(', ', $distinct));
          }
  
          return sprintf($select, $modifiers, $distinct, implode(', ', $normalized));
      }
code_tokens: protected function _buildSelectPart ( $ parts , $ query , $ generator ) { $ driver = $ query -> getConnection ( ) -> getDriver ( ) ; $ select = 'SELECT%s %s%s' ; if ( $ this -> _orderedUnion && $ query -> clause ( 'union' ) ) { $ select = '(SELECT%s %s%s' ; } $ distinct = $ query -> clause ( 'distinct' ) ; $ modifiers = $ this -> _buildModifierPart ( $ query -> clause ( 'modifier' ) , $ query , $ generator ) ; $ normalized = [ ] ; $ parts = $ this -> _stringifyExpressions ( $ parts , $ generator ) ; foreach ( $ parts as $ k => $ p ) { if ( ! is_numeric ( $ k ) ) { $ p = $ p . ' AS ' . $ driver -> quoteIdentifier ( $ k ) ; } $ normalized [ ] = $ p ; } if ( $ distinct === true ) { $ distinct = 'DISTINCT ' ; } if ( is_array ( $ distinct ) ) { $ distinct = $ this -> _stringifyExpressions ( $ distinct , $ generator ) ; $ distinct = sprintf ( 'DISTINCT ON (%s) ' , implode ( ', ' , $ distinct ) ) ; } return sprintf ( $ select , $ modifiers , $ distinct , implode ( ', ' , $ normalized ) ) ; }
docstring: Helper function used to build the string representation of a SELECT clause,
  it constructs the field list taking care of aliasing and
  converting expression objects to string. This function also constructs the
  DISTINCT clause for the query.
  
  @param array $parts list of fields to be transformed to string
  @param \Cake\Database\Query $query The query that is being compiled
  @param \Cake\Database\ValueBinder $generator the placeholder generator to be used in expressions
  @return string
docstring_tokens: Helper function used to build the string representation of a SELECT clause it constructs the field list taking care of aliasing and converting expression objects to string . This function also constructs the DISTINCT clause for the query .