I have a field in a Django model to store unique (hash values). It turns out that the database (MySQL / inno) does not perform case-sensitive searches of this type (VARCHAR), even if I explicitly tell Django that it does case-sensitive searches Document.objects.get(hash__exact="abcd123"). So "abcd123" and "ABcd123" are back, which I donβt want.
class document(models.Model):
filename = models.CharField(max_length=120)
hash = models.CharField(max_length=33 )
I can change the "hash field" to BinaryField, so in the database it becomes LONGBLOB, and it does a case-sensitive search (and it works). However, this does not seem to me very effective. Is there a better way (in Django) to do this, for example, add "utf8 COLLATE"? or what would be the right field in this situation? (yes, I know that I could use PostgreSQL instead.)
source
share