Skip to content

Commit 3a69d13

Browse files
committed
Merge branch 'release/3.0.1'
2 parents f19fab4 + 1e0b9c5 commit 3a69d13

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
All notable changes to this project will be documented in this file. This project adheres to
44
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
55

6+
## [3.0.1] - 2023-04-03
7+
8+
### Fixed
9+
10+
- [#29](https://github.com/laravel-json-api/eloquent/pull/29) Avoid unnecessary query when there is no need to count a
11+
relationship.
12+
613
## [3.0.0] - 2023-02-14
714

815
### Changed

src/QueryBuilder/ModelLoader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ public function loadMissing($includePaths): self
123123
*/
124124
public function loadCount($countable): self
125125
{
126-
$counter = new CountableLoader(
127-
$this->schema,
128-
CountablePaths::cast($countable)
129-
);
126+
$paths = CountablePaths::cast($countable);
130127

131-
$this->target->loadCount($counter->getRelations());
128+
if ($paths->isNotEmpty()) {
129+
$counter = new CountableLoader($this->schema, $paths);
130+
$this->target->loadCount($counter->getRelations());
131+
}
132132

133133
return $this;
134134
}

0 commit comments

Comments
 (0)