-
-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Labels
Description
Similar to #264 but triggered with a join on two tables.
Description
Say you have entities A, B, and A has a OneToMany relation with B. I wanted to avoid multiple db lookups so I have added fetch: 'EAGER' on A's OneToMany attribute.
Steps to reproduce
Create 2 entities with binary uuid IDs and link them with a OneToMany relation with fetch: 'EAGER'
Expected behavior
Looking up A and all its B's would be done in one query.
Screenshots or output
Actual behavior: crash on vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPerister.php:1911:
UnhandledMatchError
HTTP 500 Internal Server Error
Unhandled match case 16
private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int
{
if (! $type instanceof ParameterType) {
$type = Type::getType((string) $type)->getBindingType();
}
return match ($type) {
ParameterType::STRING => ArrayParameterType::STRING,
ParameterType::INTEGER => ArrayParameterType::INTEGER,
ParameterType::ASCII => ArrayParameterType::ASCII,
};
}In our case $type is 16, which is ParameterType::BINARY.
Environment details
- version of this package: 2.0.0
- PHP version: 8.3
- OS: Ubuntu 24.04
Additional context
Changing the function above with this:
private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int
{
if (! $type instanceof ParameterType) {
$type = Type::getType((string) $type)->getBindingType();
}
return match ($type) {
ParameterType::STRING, ParameterType::BINARY => ArrayParameterType::STRING,
ParameterType::INTEGER => ArrayParameterType::INTEGER,
ParameterType::ASCII => ArrayParameterType::ASCII,
};
}solves both problems:
- it works
- there are 7 queries on my page vs 9 before, showing that eagerly fetching (e.g. joining tables on the 1st query) optimizes db access and increase performance
Reactions are currently unavailable