﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24751	hstore isnull lookup fails	mrAdm	Tim Graham <timograham@…>	"{{{
from django.db import models
from django.contrib.postgres.fields import HStoreField


class HStoreModel(Model):
    hstore_field = HStoreField()
}}}
Execute the query:
{{{
HStoreModel.objects.create(hstore_field={'a': None})
HStoreModel.objects.filter(hstore_field__a__isnull=True)
# or non existing key
HStoreModel.objects.filter(hstore_field__b__isnull=True)
}}}
Exception:
{{{
Traceback (most recent call last):
  File ""/vagrant/manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py"", line 338, in execute_from_command_line
    utility.execute()
  File ""/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py"", line 312, in execute
    django.setup()
  File ""/usr/local/lib/python2.7/dist-packages/django/__init__.py"", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File ""/usr/local/lib/python2.7/dist-packages/django/apps/registry.py"", line 115, in populate
    app_config.ready()
  File ""/vagrant/st/apps.py"", line 12, in ready
    print HStoreModel.objects.filter(hstore_field__a__isnull=True)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 138, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 162, in __iter__
    self._fetch_all()
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 965, in _fetch_all
    self._result_cache = list(self.iterator())
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 238, in iterator
    results = compiler.execute_sql()
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py"", line 829, in execute_sql
    cursor.execute(sql, params)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py"", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/utils.py"", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: operator does not exist: hstore -> boolean
LINE 1: ...storemodel"" WHERE ""st_hstoremodel"".""hstore_field"" -> 'a' IS ...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
}}}
Wrong SQL syntax?:
{{{
WHERE ""st_hstoremodel"".""hstore_field"" -> 'b' IS NULL
}}}
Maybe you need this:
{{{
WHERE (""st_hstoremodel"".""hstore_field"" -> 'b') IS NULL
}}}"	Bug	closed	contrib.postgres	1.8	Release blocker	fixed	hstore		Accepted	1	0	0	0	0	0
