Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#24844 closed Bug (fixed)

HStore Form Field falsely report has_changed

Reported by: Ramez Issac Owned by: Andrea Grandi
Component: contrib.postgres Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description

Consider this simple Test

from django import forms
from django.contrib.postgres.forms import HStoreField


class HStoreForm(forms.Form):
    f1 = HStoreField()


class TextForm(forms.Form):
    f1 = forms.Textarea()


form_w_hstore = HStoreForm()
assert form_w_hstore.has_changed() is False #Fails

form_w_textarea = TextForm()
assert form_w_textarea.has_changed() is False #Passes

Change History (6)

comment:1 Changed 5 years ago by Andrea Grandi

Triage Stage: UnreviewedAccepted

Triaged in this example project https://github.com/andreagrandi/django-ticket-24844
Running the tests with: python manage.py test
they fails with:

(django18)➜  ticket_24844_hstore git:(master) python manage.py test
Creating test database for alias 'default'...
E
======================================================================
ERROR: hstore.tests (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: hstore.tests
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "/Users/andrea/Projects/Django/ticket-24844-hstore/ticket_24844_hstore/hstore/tests.py", line 16, in <module>
    assert form_w_hstore.has_changed() is False #Fails
AssertionError


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
Destroying test database for alias 'default'...

comment:2 Changed 5 years ago by Andrea Grandi

Owner: set to Andrea Grandi
Status: newassigned

comment:3 Changed 5 years ago by Andrea Grandi

Has patch: set

I try to fix the bug with this PR https://github.com/django/django/pull/4705

comment:4 Changed 5 years ago by Florian Apolloner <florian@…>

Resolution: fixed
Status: assignedclosed

In 43b2d88:

Fixed #24844 -- Corrected has_changed implementation for HStoreField.

comment:5 Changed 5 years ago by Tim Graham <timograham@…>

In f4cb350c:

Added release notes for refs #24844.

comment:6 Changed 5 years ago by Tim Graham <timograham@…>

In 62c19a21:

Fixed #24844 -- Corrected has_changed implementation for HStoreField.

Backport of 43b2d88a5b9cfb151ccf7ac861f2750e70c0e2c4 from master

Note: See TracTickets for help on using tickets.
Back to Top