Django: SQLSTATE=42818\r SQLCODE=-401, when viewing history on admin pages

110 views
Skip to first unread message

Helgi

unread,
Nov 3, 2009, 5:05:58 AM11/3/09
to ibm_db
I'm using:
python 2.5.4
ibm_db-1.0-py2.5
ibm_db_django-0.1.4-py2.5
django 1.1
DB2/AIX64 SQL09054

models.py:

from django.db import models
class TestModel(models.Model):
testField = models.IntegerField()

admin.py:

from inner.testapp.models import TestModel
from django.contrib import admin
admin.site.register(TestModel)

To repeat the error:

python manage.py startapp testapp
python manage.py syncdb
python manage.py runserver
Goto test model: http://localhost:8000/admin/testapp/testmodel/
Add one entry
View the entry: http://localhost:8000/admin/testapp/testmodel/1/
Click on history: http://localhost:8000/admin/testapp/testmodel/1/history/

Error:

TemplateSyntaxError at /admin/testapp/testmodel/1/history/

Caught an exception while rendering: ibm_db_dbi::ProgrammingError:
[IBM][CLI Driver][DB2/AIX64] SQL0401N The data types of the operands
for the operation "=" are not compatible. SQLSTATE=42818\r
SQLCODE=-401

Original Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
File "C:\Python25\Lib\site-packages\django\template\defaulttags.py",
line 242, in render
if (value and not ifnot) or (ifnot and not value):
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
112, in __nonzero__
iter(self).next()
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
106, in _result_iter
self._fill_cache()
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
692, in _fill_cache
self._result_cache.append(self._iter.next())
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
238, in iterator
for row in self.query.results_iter():
File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 287, in results_iter
for rows in self.execute_sql(MULTI):
File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 2369, in execute_sql
cursor.execute(sql, params)
File "C:\Python25\Lib\site-packages\django\db\backends\util.py",
line 19, in execute
return self.cursor.execute(sql, params)
File "C:\Python25\Lib\site-packages\ibm_db_django\base.py", line
189, in execute
return super(DB2CursorWrapper, self).execute(operation,
parameters)
File "c:\python25\lib\site-packages\ibm_db-1.0-py2.5-win32.egg
\ibm_db_dbi.py", line 1139, in execute
self._prepare_helper(operation)
File "c:\python25\lib\site-packages\ibm_db-1.0-py2.5-win32.egg
\ibm_db_dbi.py", line 995, in _prepare_helper
raise _get_exception(inst)
ProgrammingError: ibm_db_dbi::ProgrammingError: [IBM][CLI Driver][DB2/
AIX64] SQL0401N The data types of the operands for the operation "="
are not compatible. SQLSTATE=42818\r SQLCODE=-401

Request Method: GET
Request URL: http://localhost:8000/admin/testapp/testmodel/1/history/
Exception Type: TemplateSyntaxError
Exception Value:

Caught an exception while rendering: ibm_db_dbi::ProgrammingError:
[IBM][CLI Driver][DB2/AIX64] SQL0401N The data types of the operands
for the operation "=" are not compatible. SQLSTATE=42818\r
SQLCODE=-401

Original Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
File "C:\Python25\Lib\site-packages\django\template\defaulttags.py",
line 242, in render
if (value and not ifnot) or (ifnot and not value):
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
112, in __nonzero__
iter(self).next()
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
106, in _result_iter
self._fill_cache()
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
692, in _fill_cache
self._result_cache.append(self._iter.next())
File "C:\Python25\Lib\site-packages\django\db\models\query.py", line
238, in iterator
for row in self.query.results_iter():
File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 287, in results_iter
for rows in self.execute_sql(MULTI):
File "C:\Python25\Lib\site-packages\django\db\models\sql\query.py",
line 2369, in execute_sql
cursor.execute(sql, params)
File "C:\Python25\Lib\site-packages\django\db\backends\util.py",
line 19, in execute
return self.cursor.execute(sql, params)
File "C:\Python25\Lib\site-packages\ibm_db_django\base.py", line
189, in execute
return super(DB2CursorWrapper, self).execute(operation,
parameters)
File "c:\python25\lib\site-packages\ibm_db-1.0-py2.5-win32.egg
\ibm_db_dbi.py", line 1139, in execute
self._prepare_helper(operation)
File "c:\python25\lib\site-packages\ibm_db-1.0-py2.5-win32.egg
\ibm_db_dbi.py", line 995, in _prepare_helper
raise _get_exception(inst)
ProgrammingError: ibm_db_dbi::ProgrammingError: [IBM][CLI Driver][DB2/
AIX64] SQL0401N The data types of the operands for the operation "="
are not compatible. SQLSTATE=42818\r SQLCODE=-401

Exception Location: C:\Python25\Lib\site-packages\django\template
\debug.py in render_node, line 81
Python Executable: C:\Python25\python.exe
Python Version: 2.5.4
Python Path: ['C:\\code\\django\\inner', 'C:\\Python25\\lib\\site-
packages\\ibm_db-1.0-py2.5-win32.egg', 'C:\\Python25\\Lib\\site-
packages\\ibm_db-0.8.0-py2.5-win32.egg', 'C:\\Windows\\system32\
\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\
\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\
\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\
\site-packages\\PIL']
Server time: Tue, 3 Nov 2009 10:01:48 +0000



Rahul

unread,
Nov 5, 2009, 5:25:02 AM11/5/09
to ibm_db
when you are doing history search in your application, in that case
django generates a sql in that sql he trying to do exact look-up on a
CLOB type column (OBJECT_ID of DJANGO_ADMIN_LOG table) which one is
not supported on DB2. for more information you can check on
http://code.google.com/p/ibm-db/wiki/ibm_db_django_README
__
Thanks & Regards,
Rahul

Helgi

unread,
Nov 6, 2009, 8:23:48 AM11/6/09
to ibm_db
Thanks for your reply. Do you have any workaround to get the history
in the admin view working?

Best regards,
Helgi Borg

On Nov 5, 10:25 am, Rahul <rahul.priyadar...@in.ibm.com> wrote:
> when you are doing history search in your application, in that case
> django generates a sql in that sql he trying to do exact look-up on a
> CLOB type column (OBJECT_ID of DJANGO_ADMIN_LOG table) which one is
> not supported on DB2. for more information you can check onhttp://code.google.com/p/ibm-db/wiki/ibm_db_django_README
> > Server time:    Tue, 3 Nov 2009 10:01:48 +0000- Hide quoted text -
>
> - Show quoted text -

Rahul

unread,
Nov 7, 2009, 10:42:15 AM11/7/09
to ibm_db
i am trying to do that. If i get some solution then i will update you.

___
Thanks,
Rahul

Rahul

unread,
Nov 10, 2009, 1:24:53 AM11/10/09
to ibm_db
there is a workaround to get working of history in admin view .

Workaround
-----------------------
go to the admin apps folder (..\django\contrib\admin) and make

following changes in models.py file.

In LogEntry class

class LogEntry(models.Model):
action_time = models.DateTimeField(_('action time'),
auto_now=True)
user = models.ForeignKey(User)
content_type = models.ForeignKey(ContentType, blank=True,
null=True)
object_id = models.TextField(_('object id'), blank=True,
null=True)
..........
........


change following line:
>>>
object_id = models.TextField(_('object id'), blank=True, null=True)
<<<

As:
>>>
object_id = models.CharField(_('object id'),max_length=3000,
blank=True, null=True)
<<<

i saw that in OBJECT_ID field only integer values are created so you
can also try
>>>
object_id = models.IntegerField(_('object id'), null=True)
<<<

use this workaround and let me know if you will get any problem.

It's looking very odd that column name is "OBJECT_ID" and its type is
"CLOB". Any one would expect "XXX_ID " column as Integers mostly. and
in history view they write sql to do exact look-up with TextField.
DB2 not support exact look-up with LOB columns (I think it is true
with other databases as well). I am going to ask same question in
django forum. may be you can also push up it there.
__
Thanks,
Rahul

Rahul

unread,
Nov 27, 2009, 4:47:02 AM11/27/09
to ibm_db
Discussions about this issue is going on in django-developers forum.
You can see this on
http://groups.google.com/group/django-developers/browse_thread/thread/f91749b81465ce04/af5902fa9d6e843f#af5902fa9d6e843f


Thanks,
Rahul Priyadarshi
Reply all
Reply to author
Forward
0 new messages