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

Error when converting Ulid to PHP (Rfc4122 vs. Base32) #3

Open
tjamps opened this issue Jul 12, 2020 · 1 comment
Open

Error when converting Ulid to PHP (Rfc4122 vs. Base32) #3

tjamps opened this issue Jul 12, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@tjamps
Copy link

tjamps commented Jul 12, 2020

I think I've found another issue while using ULID generators, but I'm not sure if the problem comes
from this package or from the Uid component itself.

When generating the value to be saved to the database, the code runs:

return $value->toRfc4122();

which will give us a string, e.g. 01734311-cfdb-1e71-a873-91eff2d332ba

The issue occurs when loading the entity from the database in Guikingone\SymfonyUid\Doctrine\Ulid\UlidType::convertToPHPValue

The $value parameters is 01734311-cfdb-1e71-a873-91eff2d332ba, and Ulid::isValid($value) returns false
(it checks first if the length of the string is 26, which it is not when the Ulid is formatted according to RFC 4122).

If we use $ulid->toBase32(); instead of $ulid->toRfc4122() when converting value to the database, everything seems to work fine.

Do you think I should open an issue to the Symfony issue tracker instead ?

@Guikingone
Copy link
Owner

Hi 👋

I'm not sure that the bug comes from Symfony, the RFC defines a specific format and as the Ulid::isValid check that the value is not over a specific length, the RFC format is not "valid" against this specification (even if perfectly valid against the RFC one 😄 )

I'm gonna take a look by the end of today to solve this issue 🙂

@Guikingone Guikingone self-assigned this Jul 13, 2020
@Guikingone Guikingone added the bug Something isn't working label Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants