Skip to content

Commit

Permalink
Add EagerLoader::disableAutoFields() and Query::disableAutoFields().
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Nov 1, 2018
1 parent 8d579fa commit 1db4d7e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ORM/Association/Loader/SelectLoader.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected function _linkField($options)
protected function _buildSubquery($query) protected function _buildSubquery($query)
{ {
$filterQuery = clone $query; $filterQuery = clone $query;
$filterQuery->enableAutoFields(false); $filterQuery->disableAutoFields();
$filterQuery->mapReduce(null, null, true); $filterQuery->mapReduce(null, null, true);
$filterQuery->formatResults(null, true); $filterQuery->formatResults(null, true);
$filterQuery->contain([], true); $filterQuery->contain([], true);
Expand Down
12 changes: 12 additions & 0 deletions src/ORM/EagerLoader.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ public function enableAutoFields($enable = true)
return $this; return $this;
} }


/**
* Disable auto loading fields of contained associations.
*
* @return $this
*/
public function disableAutoFields()
{
$this->_autoFields = false;

return $this;
}

/** /**
* Gets whether or not contained associations will load fields automatically. * Gets whether or not contained associations will load fields automatically.
* *
Expand Down
12 changes: 12 additions & 0 deletions src/ORM/Query.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1374,6 +1374,18 @@ public function enableAutoFields($value = true)
return $this; return $this;
} }


/**
* Disables automatically appending fields.
*
* @return $this
*/
public function disableAutoFields()
{
$this->_autoFields = false;

return $this;
}

/** /**
* Gets whether or not the ORM should automatically append fields. * Gets whether or not the ORM should automatically append fields.
* *
Expand Down

0 comments on commit 1db4d7e

Please sign in to comment.