File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -434,10 +434,13 @@ def clean_fields(self):
434434 data = self ._d_ .get (name , None )
435435 try :
436436 # save the cleaned value
437- self . _d_ [ name ] = field .clean (data )
437+ data = field .clean (data )
438438 except ValidationException as e :
439439 errors .setdefault (name , []).append (e )
440440
441+ if name in self ._d_ or data not in ([], {}, None ):
442+ self ._d_ [name ] = data
443+
441444 if errors :
442445 raise ValidationException (errors )
443446
Original file line number Diff line number Diff line change @@ -32,6 +32,19 @@ class MyMultiSubDoc(MyDoc2, MySubDoc):
3232class DocWithNested (document .DocType ):
3333 comments = field .Nested (properties = {'title' : field .String ()})
3434
35+ class SimpleCommit (document .DocType ):
36+ files = field .String (multi = True )
37+
38+ class Meta :
39+ index = 'test-git'
40+
41+ def test_multi_works_after_doc_has_been_saved (write_client ):
42+ c = SimpleCommit ()
43+ c .full_clean ()
44+ c .files .append ('setup.py' )
45+
46+ assert c .to_dict () == {'files' : ['setup.py' ]}
47+
3548def test_null_value_for_object ():
3649 d = MyDoc (inner = None )
3750
@@ -317,6 +330,6 @@ def test_search_with_custom_alias_and_index(mock_client):
317330 search_object = MyDoc .search (
318331 using = "staging" ,
319332 index = ["custom_index1" , "custom_index2" ])
320-
333+
321334 assert search_object ._using == "staging"
322335 assert search_object ._index == ["custom_index1" , "custom_index2" ]
You can’t perform that action at this time.
0 commit comments