File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -952,6 +952,31 @@ class Doc(Document):
952952 assert "oops" == delta [0 ]["users.007.rolist" ][0 ]["type" ]
953953 assert uinfo .id == delta [0 ]["users.007.info" ]
954954
955+ def test_delta_on_dict (self ):
956+ class MyDoc (Document ):
957+ dico = DictField ()
958+
959+ MyDoc .drop_collection ()
960+
961+ MyDoc (dico = {"a" : {"b" : 0 }}).save ()
962+
963+ mydoc = MyDoc .objects .first ()
964+ assert mydoc ._get_changed_fields () == []
965+ mydoc .dico ["a" ]["b" ] = 0
966+ assert mydoc ._get_changed_fields () == []
967+ mydoc .dico ["a" ] = {"b" : 0 }
968+ assert mydoc ._get_changed_fields () == []
969+ mydoc .dico = {"a" : {"b" : 0 }}
970+ assert mydoc ._get_changed_fields () == []
971+ mydoc .dico ["a" ]["c" ] = 1
972+ assert mydoc ._get_changed_fields () == ["dico.a.c" ]
973+ mydoc .dico ["a" ]["b" ] = 2
974+ mydoc .dico ["d" ] = 3
975+ assert mydoc ._get_changed_fields () == ["dico.a.c" , "dico.a.b" , "dico.d" ]
976+
977+ mydoc ._clear_changed_fields ()
978+ assert mydoc ._get_changed_fields () == []
979+
955980
956981if __name__ == "__main__" :
957982 unittest .main ()
You can’t perform that action at this time.
0 commit comments