FIX EV3-473 producer_aliases.normalized_name collation ékezet-ütközése
A MySQL utf8mb4_unicode_ci collationja ékezet-érzéketlen (KONIG = KÖNIG), ezért a unique index ütközést jelzett két, a NameNormalizer szerint különböző névre - ezt csak a valódi EV3-357 jelentésekkel futtatott producers:alias-backfill buktatta le (König-Units Kft csoport). A normalized_name oszlop mostantól utf8mb4_bin collationt használ. Ezzel a fejlesztői gépen (a doksi eredeti mérésének gépén) a valódi backfill 235 aliast hozott létre, és a Voyagex/pribofood mérés 61/172-ről 0-ra csökkent - a sikerkritérium teljesült.
This commit is contained in:
parent
f83ce54e2f
commit
0cbc8c2f58
@ -15,7 +15,13 @@ public function up(): void
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('producer_id')->constrained('producers')->cascadeOnDelete();
|
$table->foreignId('producer_id')->constrained('producers')->cascadeOnDelete();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('normalized_name')->unique();
|
// utf8mb4_bin: a projekt alapértelmezett collationja (utf8mb4_unicode_ci)
|
||||||
|
// ékezet-érzéketlen, tehát "KONIG" és "KÖNIG" ütközne az unique indexben,
|
||||||
|
// holott a NameNormalizer szándékosan NEM old meg ékezeteket (ez a szigorú
|
||||||
|
// automatikus párosítás; az ékezet-tűrés csak a laza javaslatoknál megy,
|
||||||
|
// lásd ProducerDeduplicator::stripAccents()). A binary collation ezt az
|
||||||
|
// eltérést zárja be a PHP- és DB-szintű egyediség-ellenőrzés között.
|
||||||
|
$table->string('normalized_name')->collation('utf8mb4_bin')->unique();
|
||||||
$table->string('source')->default('backfill');
|
$table->string('source')->default('backfill');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->userIdFields();
|
$table->userIdFields();
|
||||||
|
|||||||
@ -641,7 +641,7 @@ CREATE TABLE `producer_aliases` (
|
|||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`producer_id` bigint(20) unsigned NOT NULL,
|
`producer_id` bigint(20) unsigned NOT NULL,
|
||||||
`name` varchar(255) NOT NULL,
|
`name` varchar(255) NOT NULL,
|
||||||
`normalized_name` varchar(255) NOT NULL,
|
`normalized_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||||
`source` varchar(255) NOT NULL DEFAULT 'backfill',
|
`source` varchar(255) NOT NULL DEFAULT 'backfill',
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
`updated_at` timestamp NULL DEFAULT NULL,
|
`updated_at` timestamp NULL DEFAULT NULL,
|
||||||
@ -1200,5 +1200,5 @@ INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (888,'2026_08_10_09
|
|||||||
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (889,'2026_08_10_090100_add_execution_fields_to_pricelist_file_lines_table',28);
|
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (889,'2026_08_10_090100_add_execution_fields_to_pricelist_file_lines_table',28);
|
||||||
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (890,'2026_08_16_090000_create_deployment_packages_table',29);
|
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (890,'2026_08_16_090000_create_deployment_packages_table',29);
|
||||||
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (892,'2026_08_24_172116_add_meter_unit_to_seller_and_amount_unit_columns',30);
|
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (892,'2026_08_24_172116_add_meter_unit_to_seller_and_amount_unit_columns',30);
|
||||||
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (893,'2026_09_18_120000_create_producer_aliases_table',31);
|
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (894,'2026_09_18_120000_create_producer_aliases_table',31);
|
||||||
commit;
|
commit;
|
||||||
|
|||||||
@ -186,3 +186,17 @@ function makeAlias(Producer $producer, string $name, string $source = 'backfill'
|
|||||||
|
|
||||||
expect(true)->toBeTrue();
|
expect(true)->toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ékezetben eltérő, de a NameNormalizer szerint különböző alias-ok egyszerre tárolhatók', function () {
|
||||||
|
// Valódi eset (EV3-473 backfill, "König-Units Kft" csoport): a MySQL alapértelmezett
|
||||||
|
// utf8mb4_unicode_ci collationja ékezet-érzéketlen, tehát "KONIG..." és "KÖNIG..."
|
||||||
|
// ütközne egy sima unique indexben, holott a NameNormalizer::normalize() szándékosan
|
||||||
|
// NEM old meg ékezeteket. A producer_aliases.normalized_name oszlopnak ezért
|
||||||
|
// utf8mb4_bin collationt kell használnia, különben ez a teszt DB-hibával bukna.
|
||||||
|
$producer = makeProducer('König-Units Kft');
|
||||||
|
|
||||||
|
makeAlias($producer, 'KONIG-UNITS KFT');
|
||||||
|
makeAlias($producer, 'König-Units');
|
||||||
|
|
||||||
|
expect(ProducerAlias::where('producer_id', $producer->id)->count())->toBe(2);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user