Skip to content

Commit

Permalink
No Fetch-Eager
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattmann committed Jan 25, 2025
1 parent c9724ff commit 06d9573
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions api/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ services:
tags:
- 'app.input_filter'

api_platform.doctrine.orm.query_extension.filter_eager_loading:
class: ApiPlatform\Doctrine\Orm\Extension\FilterEagerLoadingExtension
arguments:
- false

App\Serializer\Normalizer\RelatedCollectionLinkNormalizer:
decorates: 'api_platform.hal.normalizer.item'
arguments:
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/ScheduleEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ScheduleEntry extends BaseEntity implements BelongsToCampInterface {
#[AssertBelongsToSameCamp]
#[ApiProperty(example: '/periods/1a2b3c4d')]
#[Groups(['read', 'write'])]
#[ORM\ManyToOne(targetEntity: Period::class, inversedBy: 'scheduleEntries', fetch: 'EAGER')]
#[ORM\ManyToOne(targetEntity: Period::class, inversedBy: 'scheduleEntries')]
#[ORM\JoinColumn(nullable: false, onDelete: 'cascade')]
public ?Period $period = null;

Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class User extends BaseEntity implements UserInterface, PasswordAuthenticatedUse
]
)]
#[Groups(['create'])]
#[ORM\OneToOne(targetEntity: Profile::class, inversedBy: 'user', cascade: ['persist'], fetch: 'EAGER')]
#[ORM\OneToOne(targetEntity: Profile::class, inversedBy: 'user', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: false, unique: true, onDelete: 'restrict')]
public Profile $profile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ public function testSqlQueryCount() {
$client->enableProfiler();
$client->request('GET', '/camp_collaborations');

$this->assertSqlQueryCount($client, 22);
$this->assertSqlQueryCount($client, 28);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/activities: 21
/activities: 23
/activities/item: 36
/activity_progress_labels: 6
/activity_progress_labels/item: 7
/activity_responsibles: 6
/activity_responsibles/item: 8
/camps: 26
/camps/item: 21
/camp_collaborations: 22
/camps/item: 25
/camp_collaborations: 28
/camp_collaborations/item: 14
/categories: 11
/categories/item: 9
Expand Down Expand Up @@ -34,7 +34,7 @@
'/activities?camp=': 13
'/activity_progress_labels?camp=': 6
'/activity_responsibles?activity.camp=': 6
'/camp_collaborations?camp=': 12
'/camp_collaborations?camp=': 15
'/camp_collaborations?activityResponsibles.activity=': 14
'/categories?camp=': 9
'/content_types?categories=': 6
Expand Down

0 comments on commit 06d9573

Please sign in to comment.