@@ -187,14 +187,12 @@ def test_create_empty_dataframe(self):
187187 self .assertIsInstance (ids , pd .Series )
188188 self .assertEqual (len (ids ), 0 )
189189
190- def test_create_converts_nan_to_none (self ):
191- """NaN values are converted to None in the payload."""
192- df = pd .DataFrame (
193- [
194- {"name" : "Contoso" , "telephone1" : "555-0100" },
195- {"name" : "Fabrikam" , "telephone1" : None },
196- ]
197- )
190+ def test_create_drops_nan_values (self ):
191+ """NaN/None values are omitted from the create payload."""
192+ df = pd .DataFrame ([
193+ {"name" : "Contoso" , "telephone1" : "555-0100" },
194+ {"name" : "Fabrikam" , "telephone1" : None },
195+ ])
198196 self .client ._odata ._create_multiple .return_value = ["guid-1" , "guid-2" ]
199197 self .client ._odata ._entity_set_from_schema_name .return_value = "accounts"
200198
@@ -203,7 +201,8 @@ def test_create_converts_nan_to_none(self):
203201 call_args = self .client ._odata ._create_multiple .call_args
204202 records_arg = call_args [0 ][2 ]
205203 self .assertEqual (records_arg [0 ], {"name" : "Contoso" , "telephone1" : "555-0100" })
206- self .assertEqual (records_arg [1 ], {"name" : "Fabrikam" , "telephone1" : None })
204+ self .assertEqual (records_arg [1 ], {"name" : "Fabrikam" })
205+ self .assertNotIn ("telephone1" , records_arg [1 ])
207206
208207 def test_create_converts_timestamps_to_iso (self ):
209208 """Timestamp values are converted to ISO 8601 strings."""
@@ -277,17 +276,29 @@ def test_update_multiple_change_columns(self):
277276 self .assertIn ("telephone1" , changes )
278277 self .assertNotIn ("accountid" , changes )
279278
280- def test_update_preserves_none_for_clearing_fields (self ):
281- """None values in update are kept as None to allow clearing fields in Dataverse."""
282- df = pd .DataFrame (
283- [
284- {"accountid" : "guid-1" , "name" : "New Name" , "telephone1" : None },
285- {"accountid" : "guid-2" , "name" : None , "telephone1" : "555-0200" },
286- ]
287- )
279+ def test_update_skips_nan_by_default (self ):
280+ """NaN/None values are skipped by default (field left unchanged on server)."""
281+ df = pd .DataFrame ([
282+ {"accountid" : "guid-1" , "name" : "New Name" , "telephone1" : None },
283+ {"accountid" : "guid-2" , "name" : None , "telephone1" : "555-0200" },
284+ ])
288285
289286 self .client .update_dataframe ("account" , df , id_column = "accountid" )
290287
288+ call_args = self .client ._odata ._update_by_ids .call_args [0 ]
289+ changes = call_args [2 ]
290+ self .assertEqual (changes [0 ], {"name" : "New Name" })
291+ self .assertEqual (changes [1 ], {"telephone1" : "555-0200" })
292+
293+ def test_update_clear_nulls_sends_none (self ):
294+ """With clear_nulls=True, NaN/None values are sent as None to clear fields."""
295+ df = pd .DataFrame ([
296+ {"accountid" : "guid-1" , "name" : "New Name" , "telephone1" : None },
297+ {"accountid" : "guid-2" , "name" : None , "telephone1" : "555-0200" },
298+ ])
299+
300+ self .client .update_dataframe ("account" , df , id_column = "accountid" , clear_nulls = True )
301+
291302 call_args = self .client ._odata ._update_by_ids .call_args [0 ]
292303 changes = call_args [2 ]
293304 self .assertEqual (changes [0 ], {"name" : "New Name" , "telephone1" : None })
0 commit comments