Skip to content

Commit

Permalink
apply TypeMap into matching/notMatching/innerJoinWith...
Browse files Browse the repository at this point in the history
apply TypeMap into matching/notMatching/innerJoinWith/leftJoinWith
  • Loading branch information
saeideng committed Sep 25, 2016
1 parent 85ed1aa commit 875d911
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ORM/Query.php
Expand Up @@ -450,7 +450,8 @@ protected function _addAssociationsToTypeMap($table, $typeMap, $associations)
*/
public function matching($assoc, callable $builder = null)
{
$this->eagerLoader()->matching($assoc, $builder);
$result = $this->eagerLoader()->matching($assoc, $builder);
$this->_addAssociationsToTypeMap($this->repository(), $this->typeMap(), $result);
$this->_dirty();

return $this;
Expand Down Expand Up @@ -521,10 +522,11 @@ public function matching($assoc, callable $builder = null)
*/
public function leftJoinWith($assoc, callable $builder = null)
{
$this->eagerLoader()->matching($assoc, $builder, [
$result = $this->eagerLoader()->matching($assoc, $builder, [
'joinType' => 'LEFT',
'fields' => false
]);
$this->_addAssociationsToTypeMap($this->repository(), $this->typeMap(), $result);
$this->_dirty();

return $this;
Expand Down Expand Up @@ -567,10 +569,11 @@ public function leftJoinWith($assoc, callable $builder = null)
*/
public function innerJoinWith($assoc, callable $builder = null)
{
$this->eagerLoader()->matching($assoc, $builder, [
$result = $this->eagerLoader()->matching($assoc, $builder, [
'joinType' => 'INNER',
'fields' => false
]);
$this->_addAssociationsToTypeMap($this->repository(), $this->typeMap(), $result);
$this->_dirty();

return $this;
Expand Down Expand Up @@ -628,11 +631,12 @@ public function innerJoinWith($assoc, callable $builder = null)
*/
public function notMatching($assoc, callable $builder = null)
{
$this->eagerLoader()->matching($assoc, $builder, [
$result = $this->eagerLoader()->matching($assoc, $builder, [
'joinType' => 'LEFT',
'fields' => false,
'negateMatch' => true
]);
$this->_addAssociationsToTypeMap($this->repository(), $this->typeMap(), $result);
$this->_dirty();

return $this;
Expand Down

0 comments on commit 875d911

Please sign in to comment.