File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -960,16 +960,22 @@ def _execute_load_batch( # noqa: C901
960960 field_info = model_fields [clean_field_name ]
961961 field_type = field_info .get ("type" , "unknown" )
962962
963- converted_value = _safe_convert_field_value (
964- field_name , value , field_type
965- )
963+ # Sanitize unique ID field values to prevent XML ID constraint violations
964+ if i == uid_index and value is not None :
965+ converted_value = to_xmlid (str (value ))
966+ else :
967+ converted_value = _safe_convert_field_value (
968+ field_name , value , field_type
969+ )
966970 processed_row .append (converted_value )
967971 else :
968972 processed_row .append (value )
969973 processed_load_lines .append (processed_row )
970974 load_lines = processed_load_lines
971975 else :
972976 log .debug (
977+ f"First load line (first 10 fields, truncated if large): "
978+ f"{ load_lines [0 ][:10 ] if load_lines and load_lines [0 ] else []} "
973979 "Model has no _fields attribute, using raw values for load method"
974980 )
975981 try :
You can’t perform that action at this time.
0 commit comments