Opened 16 years ago

Closed 16 years ago

#7612 closed (worksforme)

ORM isn't finding Unicode names with special characters with MySQL and UTF8 tables

Reported by: mattdennewitz Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: mysql unicode orm
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django's ORM doesn't seem to be able to select records by a field w/ special characters in the criteria. For example: it's properly inserted a record who's unicode "name" property has a cedilla, but when looking up the record w/ the same unicode "name" variable it used to insert, the ORM raises DoesNotExist.

Im using MySQL 5 w/ UTF8 tables and unicode collation and Django svn rev. 7826 on OSX Leopard

Change History (2)

comment:1 by mattdennewitz, 16 years ago

These are the last two queries executed before the time of death:

Exception: [{'time': '0.001', 'sql': u'SELECT `entities_entity`.`id`, `entities_entity`.`name`, `entities_entity`.`is_active`, `entities_entity`.`created_date` FROM `entities_entity` WHERE `entities_entity`.`name` = BINARY Fran\xe7oiz Breut '}, {'time': '0.000', 'sql': u'INSERT INTO `entities_entity` (`name`, `is_active`, `created_date`) VALUES (Fran\xe7oiz Breut, True, 2008-07-02 14:49:52)'}]

comment:2 by Jacob, 16 years ago

Resolution: worksforme
Status: newclosed

Django's got plenty of regression tests that ensure it works correctly with Unicode data (see tests/modeltests/basic just for a few), so this is likely something going on in your code. For example, if you're using Unicode literals in your code and haven't properly declared the source file's encoding you could get errors just like this.

I'm closing this ticket "worksforme" since Unicode data has worked in Django for many, many others. Please reopen with more details if you're convinced it's a Django bug, but please first look into what it could be in your code since that's probably where the problem lies.

Note: See TracTickets for help on using tickets.
Back to Top