Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16592 -- More test changes and documentation to account for My…

…SQL's casual relationship with sanity. Thanks to Jim Dalton for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16787 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8d6c2517315660fbf9e69ae6b7595f33a10e5e43 1 parent dafb495
Russell Keith-Magee authored September 10, 2011
13  docs/ref/databases.txt
@@ -326,6 +326,19 @@ storage engine, you have a couple of options.
326 326
 
327 327
 .. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB
328 328
 
  329
+Table names
  330
+-----------
  331
+
  332
+There are `known issues`_ in even the latest versions of MySQL that can cause the
  333
+case of a table name to be altered when certain SQL statements are executed
  334
+under certain conditions. It is recommended that you use lowercase table
  335
+names, if possible, to avoid any problems that might arise from this behavior.
  336
+Django uses lowercase table names when it auto-generates table names from
  337
+models, so this is mainly a consideration if you are overriding the table name
  338
+via the :class:`~django.db.models.Options.db_table` parameter.
  339
+
  340
+.. _known issues: http://bugs.mysql.com/bug.php?id=48875
  341
+
329 342
 Notes on specific fields
330 343
 ------------------------
331 344
 
7  docs/ref/models/options.txt
@@ -61,6 +61,13 @@ If your database table name is an SQL reserved word, or contains characters that
61 61
 aren't allowed in Python variable names -- notably, the hyphen -- that's OK.
62 62
 Django quotes column and table names behind the scenes.
63 63
 
  64
+.. admonition:: Use lowercase table names for MySQL
  65
+
  66
+    It is strongly advised that you use lowercase table names when you override
  67
+    the table name via ``db_table``, particularly if you are using the MySQL
  68
+    backend. See the :ref:`MySQL notes <mysql-notes>` for more details.
  69
+
  70
+
64 71
 ``db_tablespace``
65 72
 -----------------
66 73
 
16  tests/modeltests/unmanaged_models/models.py
@@ -12,7 +12,7 @@ class A01(models.Model):
12 12
     f_b = models.IntegerField()
13 13
 
14 14
     class Meta:
15  
-        db_table = 'A01'
  15
+        db_table = 'a01'
16 16
 
17 17
     def __unicode__(self):
18 18
         return self.f_a
@@ -23,7 +23,7 @@ class B01(models.Model):
23 23
     f_b = models.IntegerField()
24 24
 
25 25
     class Meta:
26  
-        db_table = 'B01'
  26
+        db_table = 'b01'
27 27
         # 'managed' is True by default. This tests we can set it explicitly.
28 28
         managed = True
29 29
 
@@ -31,12 +31,12 @@ def __unicode__(self):
31 31
         return self.f_a
32 32
 
33 33
 class C01(models.Model):
34  
-    mm_a = models.ManyToManyField(A01, db_table='D01')
  34
+    mm_a = models.ManyToManyField(A01, db_table='d01')
35 35
     f_a = models.CharField(max_length=10, db_index=True)
36 36
     f_b = models.IntegerField()
37 37
 
38 38
     class Meta:
39  
-        db_table = 'C01'
  39
+        db_table = 'c01'
40 40
 
41 41
     def __unicode__(self):
42 42
         return self.f_a
@@ -49,7 +49,7 @@ class A02(models.Model):
49 49
     f_a = models.CharField(max_length=10, db_index=True)
50 50
 
51 51
     class Meta:
52  
-        db_table = 'A01'
  52
+        db_table = 'a01'
53 53
         managed = False
54 54
 
55 55
     def __unicode__(self):
@@ -57,7 +57,7 @@ def __unicode__(self):
57 57
 
58 58
 class B02(models.Model):
59 59
     class Meta:
60  
-        db_table = 'B01'
  60
+        db_table = 'b01'
61 61
         managed = False
62 62
 
63 63
     fk_a = models.ForeignKey(A02)
@@ -75,7 +75,7 @@ class C02(models.Model):
75 75
     f_b = models.IntegerField()
76 76
 
77 77
     class Meta:
78  
-        db_table = 'C01'
  78
+        db_table = 'c01'
79 79
         managed = False
80 80
 
81 81
     def __unicode__(self):
@@ -86,7 +86,7 @@ class Intermediate(models.Model):
86 86
     c02 = models.ForeignKey(C02, db_column="c01_id")
87 87
 
88 88
     class Meta:
89  
-        db_table = 'D01'
  89
+        db_table = 'd01'
90 90
         managed = False
91 91
 
92 92
 #

0 notes on commit 8d6c251

Please sign in to comment.
Something went wrong with that request. Please try again.