#8548: Lengthy verbose_name results in fatal mysql 'warning' error during 
syncdb.
-----------------------------------------+----------------------------------
          Reporter:  [EMAIL PROTECTED]  |         Owner:  nobody    
            Status:  new                 |     Milestone:  post-1.0  
         Component:  django-admin.py     |       Version:  1.0-beta-1
        Resolution:                      |      Keywords:            
             Stage:  Accepted            |     Has_patch:  0         
        Needs_docs:  0                   |   Needs_tests:  0         
Needs_better_patch:  0                   |  
-----------------------------------------+----------------------------------
Changes (by mtredinnick):

  * needs_better_patch:  => 0
  * component:  Database wrapper => django-admin.py
  * needs_tests:  => 0
  * milestone:  => post-1.0
  * needs_docs:  => 0
  * stage:  Unreviewed => Accepted

Old 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

New description:

 {{{
 #!python
 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:
 {{{
 #!sql
 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
 }}}

Comment:

 (Fixed description. The preview button is your friend.)

 This problem should be caught by the `validate` command for `django-
 admin.py`. That's the most logical fix.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8548#comment:1>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to