Indexer fails with null values

2 views
Skip to first unread message

AP

unread,
Jul 13, 2010, 12:51:43 PM7/13/10
to Djapian Users
Hi!

The indexer fails at processing null values in database fields:

8<---------------------------------------------------------------------------------------
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/management/commands/index.py", line 166, in handle
update_changes(verbose, timeout, not make_daemon, per_page,
commit_each)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/db/transaction.py", line 338, in _commit_manually
return func(*args, **kw)
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/management/commands/index.py", line 75, in update_changes
commit_each
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/indexer.py", line 233, in update
index_value = field.convert(value, self._model)
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/indexer.py", line 44, in convert
value = '%012d' % field_value
TypeError: %d format: a number is required, not NoneType
8<---------------------------------------------------------------------------------------

The affected field is marked with "null=True" in the django model. I
solved this by adding the following line to the convert method of the
Field class (file indexer.py line 34):

8<---------------------------------------------------------------------------------------
def convert(self, field_value, model):
"""
Generates index values (for sorting) for given field value and its
content type
"""
if field_value is None:
return None
# If it is a model field make some postprocessing of its value
[...]
8<---------------------------------------------------------------------------------------

I'm using djapian 2.3.1 with django 1.2.1

--
Bye, Andreas

Alex Koshelev

unread,
Jul 13, 2010, 7:21:05 PM7/13/10
to djapia...@googlegroups.com
Hi, Andreas!

It seems to be the bug. Please add this description to issue tracker with you patch. We will try to reproduce and fix it.

---
Alexander Koshelev



--
You received this message because you are subscribed to the Google Groups "Djapian Users" group.
To post to this group, send email to djapia...@googlegroups.com.
To unsubscribe from this group, send email to djapian-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/djapian-users?hl=en.


Reply all
Reply to author
Forward
0 new messages