[Django] #18959: Error message for table names > 50 characters is very poor.

8 views
Skip to first unread message

Django

unread,
Sep 14, 2012, 1:34:04 PM9/14/12
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------+--------------------
Reporter: slacy | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
If you try to create a model with a table name > 50 characters (and you've
enabled django.contrib.auth) then you get a very poor error message when
running syncdb.

For example:


{{{
env src/tmp/qdel$ python ./manage.py syncdb
Creating tables ...
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 443, in
execute_from_command_line
utility.execute()
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/commands/syncdb.py", line 110, in
handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/core/management/sql.py", line 189, in
emit_post_sync_signal
interactive=interactive, db=db)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/contrib/auth/management/__init__.py", line 54, in
create_permissions
auth_app.Permission.objects.bulk_create(objs)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/models/manager.py", line 140, in bulk_create
return self.get_query_set().bulk_create(*args, **kwargs)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/models/query.py", line 416, in bulk_create
self.model._base_manager._insert(objs_without_pk, fields=[f for f in
fields if not isinstance(f, AutoField)], using=self.db)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/models/manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/models/query.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 910, in execute_sql
cursor.execute(sql, params)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/home/slacy/src/tmp/env/local/lib/python2.7/site-
packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in
execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: value too long for type character
varying(50)

}}}


* Doesn't tell me which model
* Doesn't say "generated table name is too long"
* Works if django.contrib.auth isn't in INSTALLED_APPS, fails otherwise.
* Can fail if model name < 50 characters when the app name is long.
(since table name is concatenation of app & model class names)

I'd guess that the solution is to catch the DatabaseError in
contrib/auth/management/__init__.py create_permissions() and log some
useful message there then re-raise.

--
Ticket URL: <https://code.djangoproject.com/ticket/18959>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 14, 2012, 2:36:20 PM9/14/12
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------+--------------------------------------
Reporter: slacy | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by charettes):

* status: new => closed
* needs_better_patch: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_docs: => 0


Comment:

Duplicate of #17763.

--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:1>

Django

unread,
Sep 14, 2012, 2:50:39 PM9/14/12
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------------+-------------------------------------
Reporter: slacy | Owner: nobody
Type: Uncategorized | Status: reopened
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Design
Has patch: 0 | decision needed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* keywords: => permission
* status: closed => reopened
* version: 1.4 => master
* resolution: duplicate =>
* stage: Unreviewed => Design decision needed


Comment:

After a second thought I think it might be worth it to display a more
meaningful error message, as proposed, until #17763 is fixed since it
might take a while for native migration to land.

I agree that the actual error message is quite confusing, it wouldn't hurt
to explain the limitation.

Re-opening as DDN.

--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:2>

Django

unread,
Sep 14, 2012, 2:51:32 PM9/14/12
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------------+-------------------------------------
Reporter: slacy | Owner: nobody

Type: Uncategorized | Status: reopened
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Design
Has patch: 0 | decision needed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* cc: charette.s@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:3>

Django

unread,
Mar 22, 2013, 3:39:05 PM3/22/13
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------+------------------------------------

Reporter: slacy | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by aaugustin):

* stage: Design decision needed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:5>

Django

unread,
Mar 23, 2013, 9:39:09 AM3/23/13
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
--------------------------------------+------------------------------------
Reporter: slacy | Owner: nobody
Type: Cleanup/optimization | Status: new

Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* type: Uncategorized => Cleanup/optimization


--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:6>

Django

unread,
Sep 8, 2013, 11:18:14 AM9/8/13
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
--------------------------------------+------------------------------------
Reporter: slacy | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by rasca):

Related to #18866 that tracks the verbose_name errores

--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:7>

Django

unread,
Feb 27, 2014, 3:48:49 PM2/27/14
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
--------------------------------------+------------------------------------
Reporter: slacy | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by anubhav9042):

As I have understood it worksforme or else if someone can help me
reproduce the problem/error if I am wrong, then it would be very helpful.

--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:8>

Django

unread,
Feb 27, 2014, 3:52:05 PM2/27/14
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------------+-------------------------------------
Reporter: slacy | Owner:
Type: | anubhav9042
Cleanup/optimization | Status: assigned

Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: permission | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anubhav9042):

* status: new => assigned
* owner: nobody => anubhav9042


--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:9>

Django

unread,
Feb 28, 2014, 9:06:46 AM2/28/14
to django-...@googlegroups.com
#18959: Error message for table names > 50 characters is very poor.
-------------------------------------+-------------------------------------
Reporter: slacy | Owner:
Type: | anubhav9042
Cleanup/optimization | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: duplicate

Keywords: permission | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* status: assigned => closed
* resolution: => duplicate


Comment:

I tried to reproduce this, but I think it's actually a duplicate of
#18866. The `auth_permission.name` column is limited to 50 characters, but
it's based on the `verbose_name` which is now validated for length < 39 so
the permission name won't be too long.

--
Ticket URL: <https://code.djangoproject.com/ticket/18959#comment:10>

Reply all
Reply to author
Forward
0 new messages