Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UuidGenerator::class generates Symfony\Component\Uid\UuidV6 with default_uuid_version: 4 #44938

Closed
@heuristicservices

Description

@heuristicservices

Symfony version(s) affected

5.4.2

Description

Given a User entity (for demonstration purposes, not related to security) annotated with

 * @ORM\Id()
 * @ORM\GeneratedValue(strategy="CUSTOM")
 * @ORM\CustomIdGenerator(class=UuidGenerator::class)
 * @ORM\Column(type="uuid")
 */
private Uuid $id;

And the framework.yml configured with

uid:
    default_uuid_version: 4

Then doctrine will unexpectedly enter a UuidV6 UUID.

INSERT INTO users (id, email) VALUES (?, ?) 1={"Symfony\\Component\\Uid\\UuidV6":"1ec6f2d7-4149-60de-ac5b-174b92ac32c9"} 2="6fbb2834-21c2-4145-9d24-cc [...]"

The article https://symfony.com/blog/new-in-symfony-5-3-uid-improvements suggests that once configured, this should be UuidV4.

I think the documentation https://symfony.com/doc/current/components/uid.html also needs updating. as it says "There is no generator to assign UUIDs automatically as the value of your entity primary keys, but you can use the following" which is unexpected, considering there is the UuidGenerator::class, even though it seems to only generate V6 UUIDs.

Thank you.

How to reproduce

An example demonstrating the issue is here: https://github.com/heuristicservices/symfony-uuid

Run

docker-compose up

Migrate with

./bin/console doctrine:migrations:migrate

Navigating to

/user/add

will add some users.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions