mirror of
https://github.com/django/django.git
synced 2025-03-26 17:20:49 +00:00
Fixed #24844 -- Corrected has_changed implementation for HStoreField.
This commit is contained in:
parent
9ef2615d49
commit
43b2d88a5b
@ -34,3 +34,13 @@ class HStoreField(forms.CharField):
|
|||||||
for key, val in value.items():
|
for key, val in value.items():
|
||||||
value[key] = six.text_type(val)
|
value[key] = six.text_type(val)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def has_changed(self, initial, data):
|
||||||
|
"""
|
||||||
|
Return True if data differs from initial.
|
||||||
|
"""
|
||||||
|
# For purposes of seeing whether something has changed, None is
|
||||||
|
# the same as an empty dict, if the data or initial value we get
|
||||||
|
# is None, replace it w/ {}.
|
||||||
|
initial_value = self.to_python(initial)
|
||||||
|
return super(forms.HStoreField, self).has_changed(initial_value, data)
|
||||||
|
@ -199,6 +199,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
if conn_timezone_name != self.timezone_name:
|
if conn_timezone_name != self.timezone_name:
|
||||||
cursor = self.connection.cursor()
|
cursor = self.connection.cursor()
|
||||||
try:
|
try:
|
||||||
|
print "UPS"
|
||||||
cursor.execute(self.ops.set_time_zone_sql(), [self.timezone_name])
|
cursor.execute(self.ops.set_time_zone_sql(), [self.timezone_name])
|
||||||
finally:
|
finally:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
@ -178,6 +178,12 @@ class TestFormField(PostgresSQLTestCase):
|
|||||||
form_field = model_field.formfield()
|
form_field = model_field.formfield()
|
||||||
self.assertIsInstance(form_field, forms.HStoreField)
|
self.assertIsInstance(form_field, forms.HStoreField)
|
||||||
|
|
||||||
|
def test_empty_field_has_not_changed(self):
|
||||||
|
class HStoreFormTest(forms.Form):
|
||||||
|
f1 = HStoreField()
|
||||||
|
form_w_hstore = HStoreFormTest()
|
||||||
|
self.assertFalse(form_w_hstore.has_changed())
|
||||||
|
|
||||||
|
|
||||||
class TestValidator(PostgresSQLTestCase):
|
class TestValidator(PostgresSQLTestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user