django-nonrel/django-dbindexer — Issue #3: Crash on nullable values
Author: Wilfred
Created: 2011-12-12 15:07:10+00:00
State: open

Taken from bitbucket: https://bitbucket.org/Wilfred/django-dbindexer/issue/6/crash-on-nullable-values

Here's a minimal test case:

models.py:

from django.db import models

class Test(models.Model):
display_name = models.CharField(max_length=400, null=True)

index:

register_index(Test, {'display_name': 'istartswith'})

traceback:

$ python2.5 manage.py shell
>>> from artproject_artwork.models import Test
>>> Test.objects.create()
Traceback (most recent call last):
File "", line 1, in
File "/home/wilfred/work/gap2/django/db/models/manager.py", line 138, in create
return self.get_query_set().create(**kwargs)
File "/home/wilfred/work/gap2/django/db/models/query.py", line 362, in create
obj.save(force_insert=True, using=self.db)
File "/home/wilfred/work/gap2/django/db/models/base.py", line 462, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/wilfred/work/gap2/django/db/models/base.py", line 573, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/home/wilfred/work/gap2/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "/home/wilfred/work/gap2/django/db/models/query.py", line 1438, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/wilfred/work/gap2/dbindexer/compiler.py", line 37, in execute_sql
resolver.convert_insert_query(self.query)
File "/home/wilfred/work/gap2/dbindexer/resolver.py", line 39, in convert_insert_query
backend.convert_insert_query(query)
File "/home/wilfred/work/gap2/dbindexer/backends.py", line 53, in convert_insert_query
self._convert_insert_query(query, lookup)
File "/home/wilfred/work/gap2/dbindexer/backends.py", line 64, in _convert_insert_query
value = lookup.convert_value(value)
File "/home/wilfred/work/gap2/dbindexer/lookups.py", line 54, in convert_value
value = self._convert_value(value)
File "/home/wilfred/work/gap2/dbindexer/lookups.py", line 175, in _convert_value
return value.lower()
AttributeError: 'NoneType' object has no attribute 'lower'