Skip to content

Commit

Permalink
Removing, for now, the join table information when using 'matching'
Browse files Browse the repository at this point in the history
Hydrating the join table with matching presents several challenges,
revisit this commit upon the first bug report asking for the extra table
info :)
  • Loading branch information
lorenzo committed Mar 22, 2014
1 parent b4a4906 commit c41f40c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/ORM/Association/BelongsToMany.php
Expand Up @@ -34,6 +34,7 @@ class BelongsToMany extends Association {
use ExternalAssociationTrait {
_options as _externalOptions;
_addFilteringCondition as _addExternalConditions;
transformRow as protected _transformRow;
}

/**
Expand Down Expand Up @@ -243,6 +244,19 @@ public function attachTo(Query $query, array $options = []) {
->attachTo($query, $options);
}

/**
* Correctly nests a result row associated values into the correct array keys inside the
* source results.
*
* @param array $row
* @return array
*/
public function transformRow($row) {
$row = $this->_transformRow($row);
unset($row[$this->junction()->alias()]);
return $row;
}

/**
* Get the relationship type.
*
Expand Down
3 changes: 3 additions & 0 deletions src/ORM/ResultSet.php
Expand Up @@ -398,6 +398,9 @@ protected function _groupResult($row) {
}

foreach($presentAliases as $alias => $present) {
if (!isset($results[$alias])) {
continue;
}
$results[$defaultAlias][$alias] = $results[$alias];
}

Expand Down

0 comments on commit c41f40c

Please sign in to comment.