Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make:entity Test --with-ulid or make:entity Test --with-ulid does not use Ulid/Uuid #1577

Open
lpotherat opened this issue Jun 26, 2024 · 3 comments
Assignees
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer

Comments

@lpotherat
Copy link

Hi there, I love using Uuids / Ulids as primaries, and I jumped on this feature !
But it looks like it works only if we don't pass any parameters php bin/console make:entity --with-uuid

How to reproduce :

Execute php bin/console make:entity Test --with-uuid ( or php bin/console make:entity Test --with-ulid )
Follow steps to class creation and quit.

Expected :
The id field created like this :

#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
    #[ORM\Id]
    #[ORM\Column(type: UuidType::NAME, unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private ?Uuid $id = null;

    public function getId(): ?Uuid
    {
        return $this->id;
    }
}

Actual result:

#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    public function getId(): ?int
    {
        return $this->id;
    }
}
@Bisb
Copy link

Bisb commented Jul 19, 2024

This occurs when the symfony/uid package is not installed. It triggers an error when executing bin/console make:entity --with-uuid without parameters, but not when specifying the entity name (e.g., bin/console make:entity --with-uuid Test).

For consistency and clarity, the latter command should probably also trigger the same error ([ERROR] You must install symfony/uid to use UUIDs as "id" (composer require symfony/uid)).

@lpotherat
Copy link
Author

Hello Bisb,

The uid package is correctly installed, and if it was not very clear, it works like a charm when you do not specify the entity.
I pushed a test repository here so it is easy to test :
https://github.com/lpotherat/symfony-maker-ulid-test
The uid package is installed and the bug is still there.

I think the consistency bug is not related to the mentionned issue, but it can for sure be addressed 👍

@Bisb
Copy link

Bisb commented Jul 21, 2024

@lpotherat

You're right, I realize now that I misunderstood the last part of your post.

It seems the root of the problem is the same, the options --with-uuid / --with-ulid are simply ignored when providing the class name.

@jrushlow jrushlow added Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer labels Aug 30, 2024
@jrushlow jrushlow self-assigned this Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants