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

Allow MySQL tables to be created using the database default character set and collation #4404

Closed
gggeek opened this issue Nov 2, 2020 · 6 comments

Comments

@gggeek
Copy link

gggeek commented Nov 2, 2020

Feature Request

Q A
New Feature yes
RFC no
BC Break yes/no

Summary

The current implementation of MySqlPlatform::buildTableOptions makes it unnecessarily hard to create "generic" php code that would be useful for creating tables that do not specify the character set and/or collation in their creation SQL statement.

As mysql allows to specify charset and collation defaults for a database, it seems a useful solution for many scenarios to allow to specify the charset/collection once, as db defaults, and then omit them from all/most table definitions.

Example usecase: bundle A creates tables, using a different charset/collation in its versions 1 and 2; bundle B creates tables that need to be joined to the tables of A, and tries to be compatible with both A.1 and A.2.

At the moment the developer is forced to specify the charset if she wants not to have 'utf8', and for older version of Doctrine this leads in cascade to having to specify collation as well (otherwise DBAL might attempt to set an invalid collation).
The default character set / collation of the database seem almost impossible to be retrieved and taken into account.

What about accepting NULL as valid options for 'charset' and 'collate', which would result in the table-creation SQL statement omitting the DEFAULT CHARACTER SET and COLLATE clauses?

@gggeek
Copy link
Author

gggeek commented Nov 2, 2020

Seems related to old issue #1529

@gggeek
Copy link
Author

gggeek commented Nov 2, 2020

Not unrelated to #2441, either

@gggeek
Copy link
Author

gggeek commented Nov 2, 2020

What about accepting NULL as valid options for 'charset' and 'collate', which would result in the table-creation SQL statement omitting the DEFAULT CHARACTER SET and COLLATE clauses?

If giving a different meaning to NULL is considered a BC, we might introduce a string value of eg. 'default' with the meaning of 'use the db default'.

Btw, the same logic can also be applied to the ENGINE specification.

@morozov
Copy link
Member

morozov commented Dec 8, 2020

This looks like the right concern to me. The DBAL shouldn't enforce such defaults. Please feel free to initiate a PR.

If giving a different meaning to NULL is considered a BC

I believe it would be a BC break because right now these options are checked via isset() and default to some non-empty values.

we might introduce a string value of eg. 'default' with the meaning of 'use the db default'.

What if we introduce temporary boolean options instead, e.g. omit_default_{charset,collate,engine}? Those would tell the DBAL to omit the corresponding default values for the options where the value isn't explicitly specified. They could be dropped in the next major version. It would be better than having magic values of the existing options.

@morozov
Copy link
Member

morozov commented Dec 12, 2021

This will be fixed in 4.0.0 by #4644.

@morozov morozov closed this as completed Dec 12, 2021
@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 Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants