File tree 1 file changed +11
-9
lines changed
fastapi_crudrouter_mongodb/core/models
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -65,17 +65,19 @@ def convert_to(self, model: BaseModel):
65
65
return model (** new_model )
66
66
67
67
def _convert_list (self , list_to_convert : list ):
68
- if isinstance (list_to_convert [0 ], dict ):
69
- new_list = []
70
- for sub_object in list_to_convert :
71
- for sub_field in sub_object :
72
- sub_value = sub_object [sub_field ]
68
+ if not isinstance (list_to_convert [0 ], dict ):
69
+ return list_to_convert
70
+ new_list = []
71
+ for sub_object in list_to_convert :
72
+ for sub_field in sub_object :
73
+ sub_value = sub_object [sub_field ]
74
+ if sub_value is not None :
73
75
sub_object [sub_field ] = (
74
- sub_value if type (sub_value ) is not ObjectId else str (sub_value )
76
+ sub_value if type (sub_value ) is not ObjectId else str (sub_value )
75
77
)
76
- new_list .append (sub_object )
77
- return new_list
78
- return list_to_convert
78
+ new_list .append (sub_object )
79
+ return new_list
80
+
79
81
80
82
def __init__ (self , ** pydict ):
81
83
super ().__init__ (** pydict )
You can’t perform that action at this time.
0 commit comments