8000 [Uuid] Regression with Doctrine · Issue #39152 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Uuid] Regression with Doctrine #39152

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

Closed
94noni opened this issue Nov 23, 2020 · 5 comments
Closed

[Uuid] Regression with Doctrine #39152

94noni opened this issue Nov 23, 2020 · 5 comments

Comments

@94noni
Copy link
Contributor
94noni commented Nov 23, 2020

Symfony version(s) affected: 5.2.0-RC2

Description
Regression from 5.2.0-RC1 on Uuid and Doctrine

How to reproduce

name : symfony/uid
versions : * v5.2.0-RC2
name : doctrine/doctrine-bundle
versions : * 2.2.1

Previous code ok:

$uuid = Uuid::fromString($request->query->get('humidor_uid'));
$humidor = $humidorRepository->findOneByUuid($uuid);

Actual same code returns null

Possible Solution
.

Additional context
It appears also that, the generation and the persistence is broken
Maybe related on changes here: v5.2.0-RC1...v5.2.0-RC2

See previous issue at #38929
Maybe related also to #39144

Thank you

@jderusse
Copy link
Member

Hello @94noni
The format of UUID and ULID changed between 5.2-RC1 and 5.2-RC2. Items that have been persisted while you are running RC1 are not compatible with query sent with RC2.

 $ show create table my_table;
 ...
-# symfony 5.2-RC1
-`my_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '(DC2Type:ulid)',

+ # symfony 5.2-RC2
+`my_id` binary(16) NOT NULL COMMENT '(DC2Type:ulid)',
 ...

Could you please check the content of the table and assert the table contains binary fileds like:

mysql> select * from my_table;
+------------------------------------+------+
| my_id                              | name |
+------------------------------------+------+
| 0x0175FC41B374F72A3B65BD44884DFFDB | demo |
+------------------------------------+------+
1 row in set (0.00 sec)

If you are still using char(36), you should perform a migration: change the type of the column and change the value of the data inside.

@94noni
Copy link
Contributor Author
94noni commented Nov 25, 2020

@jderusse thank you for this explanation, will try it very soon and report back (and close the issue if it is ok)

@94noni
Copy link
Contributor Author
94noni commented Nov 25, 2020

@jderusse

yes indeed, they are represented like this in database char(36) with value like 9df9ec44-ac4b-4f8d-ae3c-673f1888734c

when adding a new prop and regenerating a migration, the SQL migration looks like:

ALTER TABLE user ADD uuid2 BINARY(16) NOT NULL COMMENT '(DC2Type:uuid)';

I will then drop those column and recreate them, repopulating the data :)
But i also sometimes insert inside those table via the UUID sql function, will try to find how to swap also

thank you!

@94noni 94noni closed this as completed Nov 25, 2020
@stof
Copy link
Member
stof commented Nov 25, 2020

@94noni if you use MySQL 8 (or newer), you can use the UUID_TO_BIN function if you need to convert a RFC4122 string (such as the one returned by MySQL's UUID function) into the binary representation in SQL.

@94noni
Copy link
Contributor Author
94noni commented Nov 25, 2020

@stof yes i've read that but now i am on 5.7
I plan to upgrade soon :) thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0