doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.86k stars 2.5k forks source link

getArrayBindingType method from the BasicEntityPersister is missing binary #11479

Open delolmo opened 4 weeks ago

delolmo commented 4 weeks ago

Bug Report

Q A
BC Break yes
Version 3.2.0

Summary

The getArrayBindingType method from the BasicEntityPersister is missing the binary type.

My guess is this:

        return match ($type) {
            ParameterType::STRING => ArrayParameterType::STRING,
            ParameterType::INTEGER => ArrayParameterType::INTEGER,
            ParameterType::ASCII => ArrayParameterType::ASCII,
        };

should be changed to this:

        return match ($type) {
            ParameterType::STRING => ArrayParameterType::STRING,
            ParameterType::INTEGER => ArrayParameterType::INTEGER,
            ParameterType::ASCII => ArrayParameterType::ASCII,
            ParameterType::BINARY => ArrayParameterType::BINARY,
        };

Need expert hands though to evaluate the problem.

Current behavior

Right now, when using binary fields, the following exception can be thrown under certain circumstances (I suspect it happens when retrieving entities with associations):

PHP Fatal error:  Uncaught UnhandledMatchError: Unhandled match case of type Doctrine\DBAL\ParameterType in (...)/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1911

How to reproduce

Not sure how to tbh.

Expected behavior

Should not throw an error.

greg0ire commented 4 weeks ago

When opening the file with my IDE, I get this warning: Match expression does not handle remaining values: Doctrine\DBAL\ParameterType::BINARY|Doctrine\DBAL\ParameterType::BOOLEAN|Doctrine\DBAL\ParameterType::LARGE_OBJECT|Doctrine\DBAL\ParameterType::NULL. You might be on to something. Would be great to have a reproducer though. A stack trace might help as well.