- Issue created by @weseze
- 🇮🇱Israel jsacksick
That is Drupal core defining the COLLATION, not Drupal Commerce.
// Note we check for the "type" key here. "mysql_type" is VARCHAR: elseif (isset($spec['type']) && $spec['type'] == 'varchar_ascii') { $sql .= ' COLLATE ascii_general_ci'; }
See the Mysql schema implementation from Drupal core: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/mysql...
- 🇧🇪Belgium weseze
I disagree.
The type "varchar_ascii" is explicitly set in some commerce schema field definitions. It could also be defined as "varchar", which would default to the collation used by the db/table and "fix" the issue.Or do you mean that Drupal core should be responsible for correctly handling these ascii mismatch errors?
If so, is there a core issue that you can refer me to? - 🇮🇱Israel jsacksick
Ok sorry you're right, replied too quickly here... We indeed explicitly specify "varchar_ascii" for certain fields... I can't recall why TBH... I've never experienced this issue previously though...
Also FYI, any new bug report / issue should be created against 8.x-2.x.
- 🇮🇱Israel jsacksick
A special varchar_ascii type is also available for limiting machine name field to US ASCII characters.
Ok so that might be why then... Only fields Commerce defines using the "varchar_ascii" type are for fields holding values that are "identifiers" / "machine names"...
- 🇮🇱Israel jsacksick
Ok, gave a closer look also at your error message.
The "problematic" field here is a standard core Entity reference field.Core explicitly defines the "varchar_ascii" type for holding the target_id of the entity type the field is targeting. This is done for config entity types (see the else here in EntityReferenceItem::schema()):
if ($target_type_info->entityClassImplements(FieldableEntityInterface::class) && $properties->getDataType() === 'integer') { $columns = [ 'target_id' => [ 'description' => 'The ID of the target entity.', 'type' => 'int', 'unsigned' => TRUE, ], ]; } else { $columns = [ 'target_id' => [ 'description' => 'The ID of the target entity.', 'type' => 'varchar_ascii', // If the target entities act as bundles for another entity type, // their IDs should not exceed the maximum length for bundles. 'length' => $target_type_info->getBundleOf() ? EntityTypeInterface::BUNDLE_MAX_LENGTH : 255, ], ]; }
So not a lot we can do here... What we did elsewhere in Commerce just follows this pattern.
- 🇮🇱Israel jsacksick
See the related issues from 📌 Throw an understandable exception when there is an attempt to load config entities with disallowed characters Needs work . There is likely one of the issues matching your bug report.
- 🇮🇱Israel jsacksick
Marking this as won't fix, as for this particular issue reported, any other entity reference field would trigger the same issue elsewhere in Drupal.