-
-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Labels
Description
I have created a new Symfony app with version 7.0.7 and doctrine/orm ^3.1. I followed the instructions to use binary UUIDs and then created a CRUD for my entities. Entity A is standalone and works well. Entity B has a ManyToOne relation to A and while the form displays fine, I can't validate it and thus create a new B.
I was able to pin the issue here, in vendor/symfony/doctrine-bridge/Form/ChoiceList/ORMQueryBuilderLoader, line 70:
// Filter out non-integer values (e.g. ""). If we don't, some
// databases such as PostgreSQL fail.
$values = array_values(array_filter($values, fn ($v) => (string) $v === (string) (int) $v || ctype_digit($v)));
} elseif (\in_array($type, ['ulid', 'uuid', 'guid'])) { // <-----
$parameterType = ArrayParameterType::STRING;now if I modify this to:
// Filter out non-integer values (e.g. ""). If we don't, some
// databases such as PostgreSQL fail.
$values = array_values(array_filter($values, fn ($v) => (string) $v === (string) (int) $v || ctype_digit($v)));
} elseif (\in_array($type, ['ulid', 'uuid', 'guid', 'uuid_binary'])) {
$parameterType = ArrayParameterType::STRING;then it works like a charm.
I feel like I have missed something in the setup of this lib but I can't pinpoint what/where.
config/packages/doctrine.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
profiling_collect_backtrace: '%kernel.debug%'
use_savepoints: true
types:
uuid_binary: Ramsey\Uuid\Doctrine\UuidBinaryTypeI also tried this in my Kernel but that does not work either:
public function boot(): void {
parent::boot();
\Doctrine\DBAL\Types\Type::addType('uuid_binary', 'Ramsey\Uuid\Doctrine\UuidBinaryType');
$entityManager = $this->getContainer()->get('doctrine.orm.default_entity_manager');
$entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('uuid_binary', 'binary');
}Reactions are currently unavailable