From e8cbc2b322d873a6fe39faca18d340ce93035087 Mon Sep 17 00:00:00 2001 From: Tim Graham <timograham@gmail.com> Date: Thu, 27 Aug 2015 09:29:13 -0400 Subject: [PATCH] Refs #2495 -- Documented that MySQL cannot have TextField(unique=True). --- docs/ref/databases.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 831d32170ae..4eb3ffda09f 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -513,6 +513,14 @@ for the field. This affects :class:`~django.db.models.CharField`, :class:`~django.db.models.SlugField` and :class:`~django.db.models.CommaSeparatedIntegerField`. +``TextField`` limitations +~~~~~~~~~~~~~~~~~~~~~~~~~ + +MySQL can index only the first N chars of a ``BLOB`` or ``TEXT`` column. Since +``TextField`` doesn't have a defined length, you can't mark it as +``unique=True``. MySQL will report: "BLOB/TEXT column '<db_column>' used in key +specification without a key length". + .. _mysql-fractional-seconds: Fractional seconds support for Time and DateTime fields