[DDC-3204] MySQL and Character Set utf8mb4 Created: 04/Jul/14  Updated: 06/Jul/14  Resolved: 06/Jul/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: eatnut Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: character_set,, mysql,, utf8

Debian Jessie, MySQL Community Server 5.7.4 m14


1. My MySQL server has default character set `utf8mb4` and collation `utf8mb4_unicode_ci`.

2. Database created for ORM has the same character set and collation as the server.

3. When I use command `doctrine orm:schema-tool:create` to create a schema, a table with character set `utf8` and collation `utf8_unicode_ci` is created (should be utf8mb4 and utf8mb4_unicode_ci).

4. When I use mysql client to create table, no problem at all.

I'm not sure is it intended or not, doctrine will just ignore utf8mb4 character set?

Comment by Marco Pivetta [ 06/Jul/14 ]

Doctrine automatically adds utf8 and utf8_unicode_ci as charset and collation in the DDL used to create tables.

You will need to manually tweak this using additional table-specific mappings.

[DDC-2139] Table collate/charset doesn't inherits from database Created: 12/Nov/12  Updated: 25/Nov/12  Resolved: 25/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM, Tools
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: William Knak Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: charset, collate, collation, mysql, utf, utf8



Using symfony2 command doctrine:schema:create the tables and Varchar fields are Collate/Charset are not inherited from database. I changed MySQL defaults to latin1/latin1_general_ci; The doctrine:database:create works; but tables and fields don't. So I found there is a code on MySqlPlataform.php:

if ( ! isset($options['charset']))

{ $options['charset'] = 'utf8'; }

if ( ! isset($options['collate']))

{ $options['collate'] = 'utf8_unicode_ci'; }

$query .= 'DEFAULT CHARACTER SET ' . $options['charset'];
$query .= ' COLLATE ' . $options['collate'];

So if you don't pass collate and charset as entity options, it will put utf8 and utf8_unicode_ci instead of dabatase default charset.

My suggestion is to change a little bit to:

if (isset($options['charset']))

{ $query .= 'DEFAULT CHARACTER SET ' . $options['charset']; }

if (isset($options['collate']))

{ $query .= ' COLLATE ' . $options['collate']; }

Comment by Benjamin Eberlei [ 25/Nov/12 ]

If we change it, then it will be like before and users disliked that very much. The decision is to use UTF-8 as default and everybody else has to change the information instead of the other way around.

Generated at Tue Aug 04 01:36:00 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.