Skip to content
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

[MySQL] Deprecate automatically setting collation to {charset}_unicode_ci as it can produce invalid collations #5353

Closed
ruudk opened this issue Apr 11, 2022 · 2 comments

Comments

@ruudk
Copy link

ruudk commented Apr 11, 2022

While working on doctrine/orm#9636 I noticed that the AbstractMySQLPlatform does something really weird.

When you define charset for the Table options, without defining the collation, it will automatically construct the collation like this:

// Collation
if (! isset($options['collation'])) {
$options['collation'] = $options['charset'] . '_unicode_ci';
}

This is naive, as it assumes that there is always a _unicode_ci for every given charset. For exampe, If I set the charset to ascii it tries to create ascii_unicode_ci which doesn't exist.

I think a deprecation should be triggered when charset is defined without specifying the collation. It teaches people to define both.

I also think that this is weird:

// Charset
if (! isset($options['charset'])) {
$options['charset'] = 'utf8';
}

It uses the default utf8 alias which points to utf8mb3 which is not compatible with UTF8. It should be utf8mb4. So maybe instead of setting this default, not do it, and or trigger a deprecation.

References:

/cc @greg0ire

@morozov
Copy link
Member

morozov commented Apr 11, 2022

The defaults will be removed in 4.0 (#4644).

I think a deprecation should be triggered when charset is defined without specifying the collation. It teaches people to define both.

That's arguable. Since MySQL doesn't force specifying the collation alongside the charset, the DBAL shouldn't either.

@ruudk ruudk closed this as completed Apr 12, 2022
@morozov morozov closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants