Author: mtredinnick Date: 2010-09-13 00:08:10 -0500 (Mon, 13 Sep 2010) New Revision: 13819
Modified: django/trunk/django/db/backends/util.py django/trunk/django/db/models/query_utils.py Log: Changed the way we create class names for deferred field models to avoid problems when people have hundreds of fields on model. Maximum class name length is now 80 characters and uses a hash when necessary. Modified: django/trunk/django/db/backends/util.py =================================================================== --- django/trunk/django/db/backends/util.py 2010-09-13 00:04:27 UTC (rev 13818) +++ django/trunk/django/db/backends/util.py 2010-09-13 05:08:10 UTC (rev 13819) @@ -105,15 +105,15 @@ return None return str(d) -def truncate_name(name, length=None): +def truncate_name(name, length=None, hash_len=4): """Shortens a string to a repeatable mangled version with the given length. """ if length is None or len(name) <= length: return name - hash = md5_constructor(name).hexdigest()[:4] + hash = md5_constructor(name).hexdigest()[:hash_len] - return '%s%s' % (name[:length-4], hash) + return '%s%s' % (name[:length-hash_len], hash) def format_number(value, max_digits, decimal_places): """ Modified: django/trunk/django/db/models/query_utils.py =================================================================== --- django/trunk/django/db/models/query_utils.py 2010-09-13 00:04:27 UTC (rev 13818) +++ django/trunk/django/db/models/query_utils.py 2010-09-13 05:08:10 UTC (rev 13819) @@ -9,6 +9,7 @@ import weakref from django.utils.copycompat import deepcopy +from django.db.backends import util from django.utils import tree from django.utils.datastructures import SortedDict @@ -262,9 +263,10 @@ # The app_cache wants a unique name for each model, otherwise the new class # won't be created (we get an old one back). Therefore, we generate the - # name using the passed in attrs. It's OK to reuse an old case if the attrs - # are identical. + # name using the passed in attrs. It's OK to reuse an existing class + # object if the attrs are identical. name = "%s_Deferred_%s" % (model.__name__, '_'.join(sorted(list(attrs)))) + name = util.truncate_name(name, 80, 32) overrides = dict([(attr, DeferredAttribute(attr, model)) for attr in attrs]) -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.