Skip to content

Commit

Permalink
Make non-null fields required
Browse files Browse the repository at this point in the history
  • Loading branch information
cdman committed May 18, 2018
1 parent 0dcdb06 commit 0c6723c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/picklefield/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class PickledObjectField(models.Field):
can still do lookups using None). This way, it is still possible to
use the ``isnull`` lookup type correctly.
"""
empty_strings_allowed = False

def __init__(self, *args, **kwargs):
self.compress = kwargs.pop('compress', False)
Expand Down
6 changes: 5 additions & 1 deletion src/picklefield/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def testDataIntegrity(self):

# Make sure the default value for default_pickled_field gets stored
# correctly and that it isn't converted to a string.
model_test = TestingModel()
model_test = TestingModel(pickle_field=1, compressed_pickle_field=1)
model_test.save()
model_test = TestingModel.objects.get(id__exact=model_test.id)
self.assertEqual((D1, S1, T1, L1), model_test.default_pickle_field)
Expand Down Expand Up @@ -200,3 +200,7 @@ def testNoCopy(self):
compressed_pickle_field='Copy Me',
non_copying_field='Dont copy me'
)

def testAllNonNullFieldsNeedToBeSetForSave(self):
with self.assertRaises(django.db.IntegrityError):
MinimalTestingModel.objects.create()

0 comments on commit 0c6723c

Please sign in to comment.