Skip to content

[DoctrineBridge] drop binary variants of UID types #39113

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

Merged
merged 1 commit into from
Nov 19, 2020

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Nov 18, 2020

Q A
Branch? 5.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets #39112
License MIT
Doc PR -

#39112 made me realize that when the DB engine doesn't have a native UUID/GUID type, there's no benefit to representing ULIDs as UUIDs.

This PR proposes to use the native GUID type for both UUIDs and ULIDs only when the DB engine provides such a type, and to use BINARY(16) when the DB engine doesn't have a native GUID type.

This leaves us in a situation where, whether the DB engine supports GUID natively or not, UUID and ULID are always stored in the most compact format.

This makes the "binary" variants useless.

MySQL 8 has functions to deal with binary GUID, and so does SQLite.

@derrabus
Copy link
Member

Is it possible to change your mind on this? Storing a UUID as string on MySQL seems to be inferior to storing it in BINARY(16). That's not only about storage, but also about index size.

MySQL ships with functions like UUID_TO_BIN() and BIN_TO_UUID(), dedicated to the binary storage of UUIDs. BINARY(16) is MySQL's poor man's version of a native UUID type. https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

And you know, if the project is already running on MySQL, "use Postgres" is not really a viable option.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Nov 19, 2020

Instead of defaulting to a varchar, we could default to binary when a DB storage doesn't have a native GUID type.
But I don't think providing a choice to users for this is really needed. Eg if MySQL has functions to represent BINARY(16) as uuids, then we should definitely use BINARY(16) when the type is declared as uuid or ulid.

@nicolas-grekas
Copy link
Member Author

@derrabus updated to my last proposal.

@fabpot
Copy link
Member

fabpot commented Nov 19, 2020

Thank you @nicolas-grekas.

@sylfabre
Copy link
Contributor

sylfabre commented Dec 3, 2020

@nicolas-grekas @javiereguiluz This conflicts with this article which needs to be updated

https://symfony.com/blog/new-in-symfony-5-2-doctrine-types-for-uuid-and-ulid

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

Successfully merging this pull request may close these issues.

6 participants