Opened 8 years ago
Last modified 8 years ago
#27901 closed Bug
Problem with Django models & MySQL & custom unicode classes — at Version 5
Reported by: | Dominique Barton | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.10 |
Severity: | Normal | Keywords: | mysql, unicode, error |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hi there
I use a custom model field (inherited from TextField
) which simply returns its value as an "enhanced" unicode
object.
Unfortunately, this will raise UnicodeErrors as MySQLdb apparently fails recognizing those values as unicode
. The comparision isn't very clever there ;)
MySQLdb has a use_unicode
flag, but I don't know how to implement it in Django and I think this is a serious bug.
I've prepared a whole test case right here: https://github.com/domibarton/django-mysql-unicode-error
I hope this is enough for a "proper" bug description.
Cheers
Domi
EDIT: It has NOTHING to do with my custom text field, this was just an example. Basically Django (or MySQLdb) fails when writing non-unicode
objects (but unicode
-inherited objects) values to a TextField
. Proof for that issue is right here: https://gist.github.com/domibarton/aa691342321f63f3511bb1ff53b946c7
Change History (5)
follow-up: 4 comment:1 by , 8 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
comment:3 by , 8 years ago
I was in the IRC channels and they sent me here. I specifically asked them "is this really OK to file a bug" and the answer was "yes it is".
Now you tell me I've to go back?
comment:4 by , 8 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
Replying to Tim Graham:
From what you provided so far, it looks like you're asking for help debugging your custom field.
No I don't need help with debugging my custom field as my custom field is not the problem! As I described before, IT IS A BUG and therefore I think this ticket is quite valid!
Let's keep it simple and ignore the fact that I'm trying to make a custom model field. Use a stock TextField
, write a value to it and then save the model. Now do the same, but use a custom unicode
class for the value. Something like that:
https://gist.github.com/domibarton/aa691342321f63f3511bb1ff53b946c7
comment:5 by , 8 years ago
Description: | modified (diff) |
---|---|
Summary: | Problem with Django & MySQL & model fields returning custom unicode classes → Problem with Django models & MySQL & custom unicode classes |
In this case, you need to explain why Django is at fault and ideally provide a patch that fixes the issue. From what you provided so far, it looks like you're asking for help debugging your custom field. For ways to get help with that, see TicketClosingReasons/UseSupportChannels.