Hi, it seems to me that the correct columntype for this datatype in mysql is
@ORM\Column(type="string", length="36") but if that is the case for all databases I do not know. Would it be possible to document what the correct datatype should be?
I also found this interesting post[1] that suggests storing uuids as a binary field. Have you considered supporting that?
Kind regards,
Tarjei
CHAR(36) is mostly inefficient, since a UUID is just a 128 bit integer. Please refer to https://github.com/ramsey/uuid-doctrine for further guidance
Ok, so the UUID method in native doctrine should not be used?
Regards
The generator strategy can be used, but it makes little sense, since UUIDs are designed so that they can be generated before DB persistence
@Ocramius I would like to change my primary keys to UUID but I'm not quite sure which doctrine type I should use. This library stores the UUID as well as CHAR(36) so I'm a bit confused.
Could you provide an example how you use UUID as primary keys in your entities?
Last time @wuethrich44 I have used this code:
/**
* @var \Ramsey\Uuid\Uuid
*
* @ORM\Id
* @ORM\Column(name="id", type="guid")
* @ORM\GeneratedValue(strategy="UUID")
* @Expose()
*/
private $id;
You'd probably use the UUIDBinaryType
On 18 Oct 2017 11:56, "Fabian Wüthrich" notifications@github.com wrote:
@Ocramius https://github.com/ocramius I would like to change my primary
keys to UUID but I'm not quite sure which doctrine type I should use. This
library https://github.com/ramsey/uuid-doctrine stores the UUID as well
as CHAR(36) so I'm a bit confused.Could you provide an example how you use UUID as primary keys in your
entities?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6312#issuecomment-337532677,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakNkqagMrX3DawkIDUE-cvtCL_P4gks5stctCgaJpZM4MQtcM
.
Most helpful comment
The generator strategy can be used, but it makes little sense, since UUIDs are designed so that they can be generated before DB persistence