Skip to content

Loading…

DBAL-423: Type GUID = VARCHAR(255) on platforms that don't have a native GUID support #1618

Closed
doctrinebot opened this Issue · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user amr:

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()

@doctrinebot

Comment created by @deeky666:

Patch PR: #465

@doctrinebot

Comment created by breiti:

With the latest support for the MyISAM-Engine merging this pull request would save some trouble.

Background/Steps to reproduce:
If you have 2 entities with guid/uuid as primary key, @ManyToMany/@JoinTable fails on MyISAM, because it would create a jointable with 2 VARCHAR(255) columns and would apply a combined primary key on these two columns. But MyISAM doesn't support keys longer than 1000 bytes so you can't create the jointable.

See: https://dev.mysql.com/doc/refman/5.6/en/myisam-storage-engine.html
{quote}The maximum key length is 1000 bytes. This can also be changed by changing the source and recompiling. For the case of a key longer than 250 bytes, a larger key block size than the default of 1024 bytes is used.{quote}

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.

@doctrinebot

Comment created by @ocramius:

[~breiti] MyISAM is niche support for the ORM - using a custom type is perfectly fine in such a case.

@doctrinebot

Comment created by breiti:

[~ocramius] 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.

@doctrinebot

Comment created by @deeky666:

[breiti] 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 [beberlei] is of the opinion that this change is a minor BC break, this PR won't make it into the master branch.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-465] was assigned:
#465

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by @ocramius:

Resolved in DBAL-731

@deeky666 deeky666 was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.5 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.