#27582: PostgreSQL form and model HStoreFields do not support null values -------------------------------------+------------------------------------- Reporter: David | Owner: (none) Hoffman | Type: Bug | Status: assigned Component: | Version: master contrib.postgres | Severity: Normal | Keywords: hstore hstorefield Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- = 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. -- Ticket URL: <https://code.djangoproject.com/ticket/27582> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.55eb5a0dfc5623618564cc60e989a648%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.