-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
🔑 UUID as primary key #565
Comments
DB column Assign (read-only) id in entity constructor /**
* @property-read string $id {primary}
*/
class Foo extends Entity
{
public function __construct()
{
parent::__construct();
$this->setReadOnlyValue('id', (new \Symfony\Component\Uid\Ulid())->toRfc4122());
}
} That should be basically it. |
@mabar |
I've never used UUID so I'm puzzled a little. What is the issue? From ORM pov there are two things:
So what do you miss? |
My example is for PostgreSQL. In MySQL char(36) should work just as fine, just way less performant. I tried to use UUID with binary in MySQL and performance was almost like with native UUID, but IDs in queries became just unreadable. In Nextras ORM it can be done by setting mapping callbacks in DbalMapper, but be aware mapping of IDs is not fully supported - described in #291 So current limitation is IDs cannot be mapped to binary for database storage and cannot be mapped to a value object in php. |
Hm, that would be good reason to proceed with 291. |
Example into docs, how to easily setup UUID as primary key.
The text was updated successfully, but these errors were encountered: