Opened 12 years ago
Closed 11 years ago
#18959 closed Cleanup/optimization (duplicate)
Error message for table names > 50 characters is very poor.
Reported by: | Steve Lacy | Owned by: | ANUBHAV JOSHI |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | permission |
Cc: | charette.s@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (10)
comment:1 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 12 years ago
Keywords: | permission added |
---|---|
Resolution: | duplicate |
Status: | closed → reopened |
Triage Stage: | Unreviewed → Design decision needed |
Version: | 1.4 → master |
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.
comment:3 by , 12 years ago
Cc: | added |
---|
comment:4 by , 12 years ago
Status: | reopened → new |
---|
comment:5 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:6 by , 12 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:7 by , 11 years ago
Related to #18866 that tracks the verbose_name errores
comment:8 by , 11 years ago
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.
comment:9 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:10 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
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.
Duplicate of #17763.