Skip to content

Commit

Permalink
Fixed a previous change that got accidentally overwritten.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastdriven committed Mar 9, 2011
1 parent 7a7407a commit d569756
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tastypie/resources.py
Expand Up @@ -616,7 +616,7 @@ def full_hydrate(self, bundle):
if field_object.attribute:
value = field_object.hydrate(bundle)

if value is not None:
if value is not None or field_object.null:
# We need to avoid populating M2M data here as that will
# cause things to blow up.
if not getattr(field_object, 'is_related', False):
Expand Down
18 changes: 5 additions & 13 deletions tests/core/tests/resources.py
Expand Up @@ -265,34 +265,26 @@ def test_full_hydrate(self):
self.assertEqual(hydrated.obj.view_count, 6)
self.assertEqual(hydrated.obj.date_joined, datetime.datetime(2010, 2, 15, 12, 0, 0))
self.assertEqual(hydrated.obj.bar, 'O HAI BAR!')


# Test that a nullable value with a previous non-null value
# can be set to None

# Test that a nullable value with a previous non-null value
# can be set to None.
nullable = NullableNameResource()

obj = nullable._meta.object_class()
obj.name = "Daniel"

null_bundle = Bundle(obj=obj, data={'name': None})
hydrated = nullable.full_hydrate(null_bundle)

self.assertTrue(hydrated.obj.name is None)



# Test that a nullable value with a previous non-null value
# is not overridden if no value was given

obj = nullable._meta.object_class()
obj.name = "Daniel"

empty_null_bundle = Bundle(obj=obj, data={})
hydrated = nullable.full_hydrate(empty_null_bundle)

self.assertEquals(hydrated.obj.name, "Daniel")


def test_obj_get_list(self):
basic = BasicResource()
self.assertRaises(NotImplementedError, basic.obj_get_list)
Expand Down

0 comments on commit d569756

Please sign in to comment.