[DBAL-423] Type GUID = VARCHAR(255) on platforms that don't have a native GUID support Created: 25/Jan/13 Updated: 08/Mar/14
I'm using MySQL with entities that have GUID ids. Therefore I'm using @ORM\Column(type="guid") for the ORM mapping. As MySQL does not have a native GUID data type, it gets mapped to type="string" with a default length of 255 -> VARCHAR(255). I don't really understand why we don't limit the length to 36, which is the fixed length for GUIDs. You could even think about using CHAR(36) for MySQL.
-> see Doctrine\DBAL\Platforms\AbstractPlatform -> getGuidTypeDeclarationSQL()
|Comment by Steve Müller [ 23/Dec/13 ]|
|Comment by Michael Kühn [ 28/Feb/14 ]|
With the latest support for the MyISAM-Engine merging this pull request would save some trouble.
Background/Steps to reproduce:
In my opinion this isn't just a "minor" issue but a major because some people can't run on MySQL with InnoDB for some reason.
|Comment by Marco Pivetta [ 28/Feb/14 ]|
Michael Kühn MyISAM is niche support for the ORM - using a custom type is perfectly fine in such a case.
|Comment by Michael Kühn [ 04/Mar/14 ]|
Marco Pivetta I agree, but i don't see why we would assume a GUID/UUID - which is per definition 36 chars long - as a 255 char long string. It would save storage space (for platforms don't supporting a native uuid type) and circle around at least 1 barrier if using MyISAM.
By the way, the PR is missing something. While it works perfectly fine the first time, every orm:schema-tool:update would output the guid-columns every time if you don't specifiy "length=36" and "fixed=true" on every GUID-@Column. IMHO the GUID-Type should implicit this both attributes in this pull request so you don't get column updates that don't change anything.
|Comment by Steve Müller [ 08/Mar/14 ]|
Michael Kühn I get your point and thanks for pointing out the remaining issue. The problem is caused by the comparator which detects differences in the column definition because the length and fixed attribute are hardcoded in the platform which is beyond comparator's knowledge. Still I think this can be fixed easily but as long as Benjamin Eberlei is of the opinion that this change is a minor BC break, this PR won't make it into the master branch.