From 2245b599a71c7c6da5c5709d7d36f71082342a66 Mon Sep 17 00:00:00 2001 From: Boulder Sprinters Date: Sun, 5 Nov 2006 01:02:13 +0000 Subject: [PATCH] [BoulderSprint] ensure default table names aren't too long git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4015 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/options.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/django/db/models/options.py b/django/db/models/options.py index ff0d112d16..0702655c2a 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -59,6 +59,8 @@ class Options(object): del self.meta def _prepare(self, model): + from django.db import backend + from django.db.backends.util import truncate_name if self.order_with_respect_to: self.order_with_respect_to = self.get_field(self.order_with_respect_to) self.ordering = ('_order',) @@ -73,6 +75,8 @@ class Options(object): # If the db_table wasn't provided, use the app_label + module_name. if not self.db_table: self.db_table = "%s_%s" % (self.app_label, self.module_name) + self.db_table = truncate_name(self.db_table, + backend.get_max_name_length) def add_field(self, field): # Insert the given field in the order in which it was created, using