diff --git a/pynamodb/attributes.py b/pynamodb/attributes.py index 2d79aa0a4..457347d2e 100644 --- a/pynamodb/attributes.py +++ b/pynamodb/attributes.py @@ -226,21 +226,7 @@ def element_serialize(self, value): return six.u(str(value)) def element_deserialize(self, value): - """ - This deserializes what we get from mongo back into a str - Serialization previously json encoded strings. This caused them to have - extra double quote (") characters. That no longer happens. - This method allows both types of serialized values to be read - :param value: - :return: - """ - result = value - try: - result = json.loads(value) - except ValueError: - # it's serialized in the new way so pass - pass - return result + return value def serialize(self, value): if value is not None: diff --git a/pynamodb/tests/test_attributes.py b/pynamodb/tests/test_attributes.py index 0806cc74d..7bae8dbc1 100644 --- a/pynamodb/tests/test_attributes.py +++ b/pynamodb/tests/test_attributes.py @@ -365,6 +365,12 @@ def test_unicode_set_serialize(self): expected = sorted([six.u('foo'), six.u('bar')]) assert attr.serialize(set([six.u('foo'), six.u('bar')])) == expected + expected = sorted([six.u('True'), six.u('False')]) + assert attr.serialize(set([six.u('True'), six.u('False')])) == expected + + expected = sorted([six.u('true'), six.u('false')]) + assert attr.serialize(set([six.u('true'), six.u('false')])) == expected + def test_round_trip_unicode_set(self): """ Round trip a unicode set @@ -373,6 +379,15 @@ def test_round_trip_unicode_set(self): orig = set([six.u('foo'), six.u('bar')]) assert orig == attr.deserialize(attr.serialize(orig)) + orig = set([six.u('true'), six.u('false')]) + assert orig == attr.deserialize(attr.serialize(orig)) + + orig = set([six.u('1'), six.u('2.8')]) + assert orig == attr.deserialize(attr.serialize(orig)) + + orig = set([six.u('[1,2,3]'), six.u('2.8')]) + assert orig == attr.deserialize(attr.serialize(orig)) + def test_unicode_set_deserialize(self): """ UnicodeSetAttribute.deserialize @@ -381,14 +396,14 @@ def test_unicode_set_deserialize(self): value = set([six.u('foo'), six.u('bar')]) assert attr.deserialize(value) == value - def test_unicode_set_deserialize_old_way(self): - """ - UnicodeSetAttribute.deserialize old way - """ - attr = UnicodeSetAttribute() - value = set([six.u('foo'), six.u('bar')]) - old_value = set([json.dumps(val) for val in value]) - assert attr.deserialize(old_value) == value + value = set([six.u('True'), six.u('False')]) + assert attr.deserialize(value) == value + + value = set([six.u('true'), six.u('false')]) + assert attr.deserialize(value) == value + + value = set([six.u('1'), six.u('2.8')]) + assert attr.deserialize(value) == value def test_unicode_set_attribute(self): """