#13710: raw() sql bug when using a model with many fields with long names
---------------------------------------------------+------------------------
Reporter: Renskers | Owner: tobias
Status: reopened | Milestone:
Component: Database layer (models, ORM) | Version: 1.2
Resolution: | Keywords: raw sql
joins deffered class
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Comment (by Renskers):
OK, did some extensive testing. Turns out, my problem has nothing to do
with the number of fields on a model. Rather, I had some fields with
unicode names, done like this:
{{{
MyModel.add_to_class(u'field_name', models.CharField(max_length=30))
}}}
I used this add_to_class way of adding fields to a model because the
fields were already defined somewhere else. But, the field names are
unicode strings (because they are also used in other languages with weird
characters). This causes the "type() argument 1 must be string, not
unicode" error in deferred_class_factory.
Now that I know this, I can cast my field names to the proper string type
before adding them to my model. But maybe it's also a good idea to cast
the name variable to a string in the deferred_class_factory function, just
to be safe (see django/db/models/query_utils.py, line 267)
Still, the size of the name variable can really get out of hand when you
have a lot of fields. In my case, it was a string with over 8000
characters...
--
Ticket URL: <http://code.djangoproject.com/ticket/13710#comment:9>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.