Skip to content

Commit

Permalink
Fixed #16592 -- More test changes and documentation to account for My…
Browse files Browse the repository at this point in the history
…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
freakboy3742 committed Sep 10, 2011
1 parent dafb495 commit 8d6c251
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
13 changes: 13 additions & 0 deletions docs/ref/databases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,19 @@ storage engine, you have a couple of options.

.. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB

Table names
-----------

There are `known issues`_ in even the latest versions of MySQL that can cause the
case of a table name to be altered when certain SQL statements are executed
under certain conditions. It is recommended that you use lowercase table
names, if possible, to avoid any problems that might arise from this behavior.
Django uses lowercase table names when it auto-generates table names from
models, so this is mainly a consideration if you are overriding the table name
via the :class:`~django.db.models.Options.db_table` parameter.

.. _known issues: http://bugs.mysql.com/bug.php?id=48875

Notes on specific fields
------------------------

Expand Down
7 changes: 7 additions & 0 deletions docs/ref/models/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ If your database table name is an SQL reserved word, or contains characters that
aren't allowed in Python variable names -- notably, the hyphen -- that's OK.
Django quotes column and table names behind the scenes.

.. admonition:: Use lowercase table names for MySQL

It is strongly advised that you use lowercase table names when you override
the table name via ``db_table``, particularly if you are using the MySQL
backend. See the :ref:`MySQL notes <mysql-notes>` for more details.


``db_tablespace``
-----------------

Expand Down
16 changes: 8 additions & 8 deletions tests/modeltests/unmanaged_models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class A01(models.Model):
f_b = models.IntegerField()

class Meta:
db_table = 'A01'
db_table = 'a01'

def __unicode__(self):
return self.f_a
Expand All @@ -23,20 +23,20 @@ class B01(models.Model):
f_b = models.IntegerField()

class Meta:
db_table = 'B01'
db_table = 'b01'
# 'managed' is True by default. This tests we can set it explicitly.
managed = True

def __unicode__(self):
return self.f_a

class C01(models.Model):
mm_a = models.ManyToManyField(A01, db_table='D01')
mm_a = models.ManyToManyField(A01, db_table='d01')
f_a = models.CharField(max_length=10, db_index=True)
f_b = models.IntegerField()

class Meta:
db_table = 'C01'
db_table = 'c01'

def __unicode__(self):
return self.f_a
Expand All @@ -49,15 +49,15 @@ class A02(models.Model):
f_a = models.CharField(max_length=10, db_index=True)

class Meta:
db_table = 'A01'
db_table = 'a01'
managed = False

def __unicode__(self):
return self.f_a

class B02(models.Model):
class Meta:
db_table = 'B01'
db_table = 'b01'
managed = False

fk_a = models.ForeignKey(A02)
Expand All @@ -75,7 +75,7 @@ class C02(models.Model):
f_b = models.IntegerField()

class Meta:
db_table = 'C01'
db_table = 'c01'
managed = False

def __unicode__(self):
Expand All @@ -86,7 +86,7 @@ class Intermediate(models.Model):
c02 = models.ForeignKey(C02, db_column="c01_id")

class Meta:
db_table = 'D01'
db_table = 'd01'
managed = False

#
Expand Down

0 comments on commit 8d6c251

Please sign in to comment.