﻿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
27582	Allow HStoreField to store null values in key: value pairs	David Hoffman	Tim Graham <timograham@…>	"= Overview

PostgreSQL allows values to be either strings or nulls in `hstore`:  https://www.postgresql.org/docs/9.5/static/hstore.html

It appears that the form and model HStoreFields do not support null values. Is this something that should be fixed?

= How to reproduce for the form field

{{{
>>> from django.contrib.postgres import forms
>>> field = forms.HStoreField()
>>> field.clean('{""a"": null}')
{u'a': u'None'} 
}}}
== Expected Behavior

The null has been converted to a string, when it should actually be the None value

= How to reproduce for the model field

{{{
>>> from django.contrib.postgres.fields import HStoreField
>>> field = HStoreField()
>>> field.clean({'a': None}, None)
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/Users/dhoffman/.envs/brain-campaign/lib/python2.7/site-packages/django/db/models/fields/__init__.py"", line 588, in clean
    self.validate(value, model_instance)
  File ""/Users/dhoffman/.envs/brain-campaign/lib/python2.7/site-packages/django/contrib/postgres/fields/hstore.py"", line 36, in validate
    params={'key': key},
ValidationError: [u'The value of ""a"" is not a string.']
}}}

== Expected Behavior

This should actually be allowed without error."	Cleanup/optimization	closed	contrib.postgres	dev	Normal	fixed	hstore hstorefield		Accepted	1	0	0	0	0	0
