Installed the latest dev build. Upon updating the database I get the following error:
dynamic_entity_reference module
Update #8001
Failed: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: ALTER TABLE {courier_template_collection} CHANGE `owner__target_id` `owner__target_id` VARCHAR(255) NOT NULL COMMENT 'The ID of the target entity.'; Array ( ) in dynamic_entity_reference_update_8001() (line 44 of /home/solution/public_html/surf-dates.com/modules/contrib/dynamic_entity_reference/dynamic_entity_reference.install).
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2769603_13.patch | 3.36 KB | chx |
| #13 | 2769603_13_fail.patch | 682 bytes | chx |
Comments
Comment #2
chx commentedCare to share a structure dump of the table in question?
Comment #3
chx commentedAlso, what's your core version.
Comment #4
platinum1 commentedThe version is 8.2.x-dev
Comment #5
jibranAs mentioned in #2. Please share the output of
drush sqlq "SHOW CREATE TABLE courier_template_collection;". It seems like you are using http://drupal.org/project/courier and the entity in question is http://cgit.drupalcode.org/courier/tree/src/Entity/TemplateCollection.php. I'll ping @dpi about it.Comment #6
jibran@chx: I'm looking at
TemplateCollection::baseFieldDefinitions()and this entity has two DER basefields. One field(owner) with cardinality 1 and other(templates) with unlimited. I don't think it is related to #2766193: Add tests for multiple base fields because field with an unlimited cardinality will have a separate table and basefield in question here isownernottemplates.Comment #7
platinum1 commentedcourier_template_collection CREATE TABLE `courier_template_collection` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `context` varchar(255) CHARACTER SET ascii DEFAULT NULL COMMENT 'The ID of the target entity.',\n `owner__target_id` int(10) unsigned DEFAULT NULL COMMENT 'The ID of the target entity.',\n `owner__target_type` varchar(32) DEFAULT NULL COMMENT 'The Entity Type ID of the target entity.',\n PRIMARY KEY (`id`),\n KEY `courier_template_collection__b3acb6e86e` (`context`),\n KEY `courier_template_collection__2d7659b160` (`owner__target_id`,`owner__target_type`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='The base table for courier_template_collection entities.'
Comment #8
jibranThank you!
Comment #9
chx commentedThis looks like a core bug (when the new spec of an alter is a varchar and has an index defined on it then the indexing shortening mechanism should fire) but fixing it there is a bother so let's just play dumb contrib author and code around it. Semantically this is more correct anyways.
Comment #11
chx commentedComment #12
jibranNice fix! Let's file a core bug as well. Can we somehow test this fix?
Comment #13
chx commentedYes, yes, we can. It's untrivial to test, it's ugly to test but it's doable.
Comment #14
jibranCreated #2770321: MySQL Schema class needs to check for existing indexes for alter queries for #9 and created #2770319: Testbot MySQL config doesn't use large prefix hiding potential errors for not failing patch in #13.
This is ready imo let's wait for @platinum1 to test it.
Comment #15
jibranThis is a mysql bug https://bugs.mysql.com/bug.php?id=68453 and as it turns out if you set
innodb_large_prefixOFFthe error will go away.I don't think we should change this at all to fix a core bug #2770321: MySQL Schema class needs to check for existing indexes for alter queries. As far as this issue is concerned I think it is a won't fix and we should fix it in core.
Comment #16
chx commentedCore doesn't support forcing large indexes (there's no ROW_FORMAT support as far as I can see) which a 255 + 32 utf8mb4 would create but semantically this is correct because machine names are ASCII and not higher Unicode characters.
Comment #17
jibranOk, let's commit #11 instead of #13. We don't need to test mysql bug in DER.
Comment #18
chx commentedWe need to, we actually need to because people will have COMPACT tables and we need to make sure we are doing the right update even for them. Yes, if the alterTable method would truncate the index itself as the core issue says it should then there would be no problem but it's core and I expect it to be not fixed any time soon since I won't. The only change we need to do there is to wrap it in
if (Database::getConnection()->driver() == 'mysql').Comment #19
chx commentedLike this.
Comment #20
chx commentedOpsie, that was just the fail patch, this is the complete one.
Comment #21
jibranSeems like all the DB drivers are happy.
Comment #22
platinum1 commentedThank you for the patch. Error is gone.
Comment #24
chx commentedThanks for the valuable report and the quick feedback! Committed.