original_string: protected function _addFilteringJoin($query, $key, $subquery)
      {
          $filter = [];
          $aliasedTable = $this->sourceAlias;
  
          foreach ($subquery->clause('select') as $aliasedField => $field) {
              if (is_int($aliasedField)) {
                  $filter[] = new IdentifierExpression($field);
              } else {
                  $filter[$aliasedField] = $field;
              }
          }
          $subquery->select($filter, true);
  
          $conditions = null;
          if (is_array($key)) {
              $conditions = $this->_createTupleCondition($query, $key, $filter, '=');
          } else {
              $filter = current($filter);
          }
  
          $conditions = $conditions ?: $query->newExpr([$key => $filter]);
  
          return $query->innerJoin(
              [$aliasedTable => $subquery],
              $conditions
          );
      }
code: protected function _addFilteringJoin($query, $key, $subquery)
      {
          $filter = [];
          $aliasedTable = $this->sourceAlias;
  
          foreach ($subquery->clause('select') as $aliasedField => $field) {
              if (is_int($aliasedField)) {
                  $filter[] = new IdentifierExpression($field);
              } else {
                  $filter[$aliasedField] = $field;
              }
          }
          $subquery->select($filter, true);
  
          $conditions = null;
          if (is_array($key)) {
              $conditions = $this->_createTupleCondition($query, $key, $filter, '=');
          } else {
              $filter = current($filter);
          }
  
          $conditions = $conditions ?: $query->newExpr([$key => $filter]);
  
          return $query->innerJoin(
              [$aliasedTable => $subquery],
              $conditions
          );
      }
code_tokens: protected function _addFilteringJoin ( $ query , $ key , $ subquery ) { $ filter = [ ] ; $ aliasedTable = $ this -> sourceAlias ; foreach ( $ subquery -> clause ( 'select' ) as $ aliasedField => $ field ) { if ( is_int ( $ aliasedField ) ) { $ filter [ ] = new IdentifierExpression ( $ field ) ; } else { $ filter [ $ aliasedField ] = $ field ; } } $ subquery -> select ( $ filter , true ) ; $ conditions = null ; if ( is_array ( $ key ) ) { $ conditions = $ this -> _createTupleCondition ( $ query , $ key , $ filter , '=' ) ; } else { $ filter = current ( $ filter ) ; } $ conditions = $ conditions ? : $ query -> newExpr ( [ $ key => $ filter ] ) ; return $ query -> innerJoin ( [ $ aliasedTable => $ subquery ] , $ conditions ) ; }
docstring: Appends any conditions required to load the relevant set of records in the
  target table query given a filter key and some filtering values when the
  filtering needs to be done using a subquery.
  
  @param \Cake\ORM\Query $query Target table's query
  @param string|array $key the fields that should be used for filtering
  @param \Cake\ORM\Query $subquery The Subquery to use for filtering
  @return \Cake\ORM\Query
docstring_tokens: Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values when the filtering needs to be done using a subquery .