diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index c34f101180..e1c584362f 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -553,8 +553,7 @@ db_config['TEST'] = { # Set collation option for mysql test database if 'mysql' in db_engine: - # Ref: https://docs.djangoproject.com/en/4.0/ref/databases/#collation-settings - db_config['TEST']['COLLATION'] = 'utf8_bin' + db_config['TEST']['COLLATION'] = 'utf8_general_ci' DATABASES = { 'default': db_config diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 1cb83b839a..d6ca9f650c 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -779,7 +779,7 @@ class Part(MPTTModel): # Raise an error if an IPN is set, and it is a duplicate if self.IPN and not allow_duplicate_ipn: - parts = Part.objects.filter(IPN=self.IPN) + parts = Part.objects.filter(IPN__iexact=self.IPN) parts = parts.exclude(pk=self.pk) if parts.exists(): diff --git a/InvenTree/part/test_part.py b/InvenTree/part/test_part.py index cb932993dc..811acebc69 100644 --- a/InvenTree/part/test_part.py +++ b/InvenTree/part/test_part.py @@ -352,10 +352,10 @@ class PartSettingsTest(TestCase): # Any duplicate IPN should raise an error Part.objects.create(name='xyz', revision='1', description='A part', IPN='UNIQUE') - # Case sensitive, so other variations don't error out: - Part.objects.create(name='xyz', revision='2', description='A part', IPN='UNIQUe') - Part.objects.create(name='xyz', revision='3', description='A part', IPN='UNIQuE') - Part.objects.create(name='xyz', revision='4', description='A part', IPN='UNIqUE') + # Case insensitive, so variations on spelling should throw an error + for ipn in ['UNiquE', 'uniQuE', 'unique']: + with self.assertRaises(ValidationError): + Part.objects.create(name='xyz', revision='2', description='A part', IPN=ipn) with self.assertRaises(ValidationError): Part.objects.create(name='zyx', description='A part', IPN='UNIQUE')