Opened 16 years ago

Last modified 9 years ago

#8548 closed

Lengthy verbose_name results in fatal mysql 'warning' error during syncdb. — at Initial Version

Reported by: samt@… Owned by: nobody
Component: Core (Management commands) Version: 1.4
Severity: Normal Keywords:
Cc: thepapermen, markus@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

class Thingie(models.Model)
#fields go here

class Meta:

verbose_name = 'A String Greater Than 50 Characters Long, Probably For The Admin'

Running 'python manage.py syncdb' results in MySQLdb trying to run the following:

INSERT INTO auth_permission (name, content_type_id, codename) VALUES (%s, %s, %s)(u'A String Greater Than 50 Characters Long, Probably For The Admin', 11, u'add_thingie')

The field name has a length restriction of 50 characters. This results in a warning 'error' being generated (_mysql_exceptions.Warning: Data truncated for column 'name' at row 1) but no further useful information. This also halts syncdb, which is also called during the test suite.

Suggestions (since I'm nowhere near qualified to contribute, yet):

  • Maybe just catch the warning and ignore it? This seems to be a display-only field, so it probably won't hurt.
  • Or maybe catch the warning and explain the cause?
  • Model validator could complain about verbose_name being too long?
  • Increase the size of the field?
  • Maybe just let google index this ticket so that the next person to google the error sees why it happened?

Traceback (most recent call last):

File "manage.py", line 11, in <module>

execute_manager(settings)

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/init.py", line 334, in execute_manager

utility.execute()

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/init.py", line 295, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/base.py", line 77, in run_from_argv

self.execute(*args, options.dict)

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/base.py", line 96, in execute

output = self.handle(*args, options)

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/base.py", line 178, in handle

return self.handle_noargs(options)

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/commands/syncdb.py", line 101, in handle_noargs

emit_post_sync_signal(created_models, verbosity, interactive)

File "/usr/local/python-x/lib/python2.5/site-packages/django/core/management/sql.py", line 205, in emit_post_sync_signal

interactive=interactive)

File "/usr/local/python-x/lib/python2.5/site-packages/django/dispatch/dispatcher.py", line 148, in send

response = receiver(signal=self, sender=sender, named)

File "/usr/local/python-x/lib/python2.5/site-packages/django/contrib/auth/management/init.py", line 28, in create_permissions

defaults={'name': name, 'content_type': ctype})

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/manager.py", line 84, in get_or_create

return self.get_query_set().get_or_create(kwargs)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/query.py", line 331, in get_or_create

obj.save()

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/base.py", line 282, in save

self.save_base(force_insert=force_insert, force_update=force_update)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/base.py", line 356, in save_base

result = manager._insert(values, return_id=update_pk)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/manager.py", line 126, in _insert

return insert_query(self.model, values, kwargs)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/query.py", line 884, in insert_query

return query.execute_sql(return_id)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/sql/subqueries.py", line 308, in execute_sql

cursor = super(InsertQuery, self).execute_sql(None)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/models/sql/query.py", line 1641, in execute_sql

cursor.execute(sql, params)

File "/usr/local/python-x/lib/python2.5/site-packages/django/db/backends/util.py", line 20, in execute

return self.cursor.execute(sql, params)

File "/usr/local/python-x/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg/MySQLdb/cursors.py", line 168, in execute
File "/usr/local/python-x/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg/MySQLdb/cursors.py", line 82, in _warning_check
File "/usr/local/python-x/lib/python2.5/warnings.py", line 62, in warn

globals)

File "/usr/local/python-x/lib/python2.5/warnings.py", line 102, in warn_explicit

raise message

_mysql_exceptions.Warning: Data truncated for column 'name' at row 1

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top