Problem/Motivation
Setting collation in the table schema for MySQL tables has no effect. Per the original report:
I would very much like to see it fixed in D7 ASAP, because it's causing major problems for my module, S3 File System. I define a table with utf8_bin collation, since I need case-sensitive primary keys, but the collation setting gets ignored, and I have to run db_query("ALTER TABLE {s3fs_file} CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin");
manually to fix it.
This bug also makes it clear that the tests for the database creation code are incomplete.
Proposed resolution
Apply any explicit collation settings in the table schema before checking for collation settings in the connection info.
Remaining tasks
Write tests (MySQL-specific, presumably - do the other core db engines purport to support table-specific collations?).
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
TBD
Original issue summary
There's a typo in DatabaseSchema_mysql::createTableSql() which makes the 'collation' setting in schema definitions get silently ignored. The schema info variable is called $table
, but it's referenced in the collation code as $info
. Since it's wrapped in a !empty()
check, PHP happily confirms that $info['collation'] is always empty, because $info is undefined.
The fix is simply to rename $info to $table, which I've done in the attached patches (this bug exists in D8 and D7).
I would very much like to see it fixed in D7 ASAP, because it's causing major problems for my module, S3 File System. I define a table with utf8_bin collation, since I need case-sensitive primary keys, but the collation setting gets ignored, and I have to run db_query("ALTER TABLE {s3fs_file} CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin");
manually to fix it.
This bug also makes it clear that the tests for the database creation code are incomplete. Unfortunately, I know nothing about drupal testing, so I can't write a patch for that.