Opened 10 years ago

Closed 10 years ago

#7383 closed (invalid)

MySql error "Truncated Incorrect Double Value" using extra()

Reported by: bcurtu Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm experiencing this error when I use the extra() function:

    def get_entrada(self,key):
        es=Entradilla.objects.extra(where=['%s=True'], params=[key])  

In this case, key variable contains the name of the object's attribute.
I'm working with django-trunk version 0.97-pre-SVN-7569 and MySQL 5.0.45

The stack trace i get is:


Request Method: POST
Request URL:
Django Version: 0.97-pre-SVN-7569
Python Version: 2.5.1
Installed Applications:
Installed Middleware:

File "/usr/lib64/python2.5/site-packages/django/core/handlers/" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib64/python2.5/site-packages/django/contrib/admin/views/" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "/usr/lib64/python2.5/site-packages/django/views/decorators/" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/usr/lib64/python2.5/site-packages/django/contrib/admin/views/" in change_stage
  338.             new_object =
File "/usr/lib64/python2.5/site-packages/django/db/models/" in save
File "/home/bcm/ws/autodesc/../autodesc/engine/" in save
  70.                 self.descripcion = self.descripcion + " " + self.get_entrada('salsa') 
File "/home/bcm/ws/autodesc/../autodesc/engine/" in get_entrada
  115.         return es[0].frase  
File "/usr/lib64/python2.5/site-packages/django/db/models/" in __getitem__
  129.             return list(qs)[0]
File "/usr/lib64/python2.5/site-packages/django/db/models/" in __len__
  55.             self._result_cache.extend(list(self._iter))
File "/usr/lib64/python2.5/site-packages/django/db/models/" in iterator
  162.         for row in self.query.results_iter():
File "/usr/lib64/python2.5/site-packages/django/db/models/sql/" in results_iter
  200.         for rows in self.execute_sql(MULTI):
File "/usr/lib64/python2.5/site-packages/django/db/models/sql/" in execute_sql
  1466.         cursor.execute(sql, params)
File "/usr/lib64/python2.5/site-packages/django/db/backends/" in execute
  18.             return self.cursor.execute(sql, params)
File "/usr/lib64/python2.5/site-packages/MySQLdb/" in execute
  165.         self._warning_check()
File "/usr/lib64/python2.5/site-packages/MySQLdb/" in _warning_check
  80.                     warn(w[-1], self.Warning, 3)
File "/usr/lib64/python2.5/" in warn
  62.                   globals)
File "/usr/lib64/python2.5/" in warn_explicit
  102.         raise message

Exception Type: Warning at /admin/engine/event/7/
Exception Value: Truncated incorrect DOUBLE value: 'salsa'


Change History (1)

comment:1 Changed 10 years ago by Karen Tracey <kmtracey@…>

Resolution: invalid
Status: newclosed

The quoting done by extra params= is not correct for column names in the database. The example here:

shows it being using for the right-hand-side only, not the left. I think your get_entrada function should be more like:

def get_entrada(self,key):
        wherespec = '`%s`=True' % key
Note: See TracTickets for help on using tickets.
Back to Top