fix: upsert_trace_profile preserves VLM fields on conflict

The ON CONFLICT DO UPDATE clause was missing vlm_* columns, causing
Face Cluster (P3) label sync to overwrite and lose VLM data.

Added COALESCE preservation for:
  vlm_description, vlm_clothing, vlm_tags, vlm_location, vlm_setting,
  vlm_lighting, vlm_weather, vlm_hand_objects, vlm_has_plants,
  vlm_has_animals, vlm_background, vlm_bg_tags, vlm_model,
  vlm_embedding, vlm_point_id
This commit is contained in:
Accusys
2026-08-22 17:27:56 +08:00
parent 11d210ee55
commit 165af40f3c
+18 -3
View File
@@ -73,9 +73,24 @@ pub async fn upsert_trace_profile(
best_confidence = COALESCE(EXCLUDED.best_confidence, {tp_table}.best_confidence), \
avg_capture_quality = COALESCE(EXCLUDED.avg_capture_quality, {tp_table}.avg_capture_quality), \
best_capture_quality = COALESCE(EXCLUDED.best_capture_quality, {tp_table}.best_capture_quality), \
avg_bbox = COALESCE(EXCLUDED.avg_bbox, {tp_table}.avg_bbox), \
best_bbox = COALESCE(EXCLUDED.best_bbox, {tp_table}.best_bbox), \
updated_at = NOW()",
avg_bbox = COALESCE(EXCLUDED.avg_bbox, {tp_table}.avg_bbox), \
best_bbox = COALESCE(EXCLUDED.best_bbox, {tp_table}.best_bbox), \
vlm_description = COALESCE(EXCLUDED.vlm_description, {tp_table}.vlm_description), \
vlm_clothing = COALESCE(EXCLUDED.vlm_clothing, {tp_table}.vlm_clothing), \
vlm_tags = COALESCE(EXCLUDED.vlm_tags, {tp_table}.vlm_tags), \
vlm_location = COALESCE(EXCLUDED.vlm_location, {tp_table}.vlm_location), \
vlm_setting = COALESCE(EXCLUDED.vlm_setting, {tp_table}.vlm_setting), \
vlm_lighting = COALESCE(EXCLUDED.vlm_lighting, {tp_table}.vlm_lighting), \
vlm_weather = COALESCE(EXCLUDED.vlm_weather, {tp_table}.vlm_weather), \
vlm_hand_objects = COALESCE(EXCLUDED.vlm_hand_objects, {tp_table}.vlm_hand_objects), \
vlm_has_plants = COALESCE(EXCLUDED.vlm_has_plants, {tp_table}.vlm_has_plants), \
vlm_has_animals = COALESCE(EXCLUDED.vlm_has_animals, {tp_table}.vlm_has_animals), \
vlm_background = COALESCE(EXCLUDED.vlm_background, {tp_table}.vlm_background), \
vlm_bg_tags = COALESCE(EXCLUDED.vlm_bg_tags, {tp_table}.vlm_bg_tags), \
vlm_model = COALESCE(EXCLUDED.vlm_model, {tp_table}.vlm_model), \
vlm_embedding = COALESCE(EXCLUDED.vlm_embedding, {tp_table}.vlm_embedding), \
vlm_point_id = COALESCE(EXCLUDED.vlm_point_id, {tp_table}.vlm_point_id), \
updated_at = NOW()",
);
let mut query = sqlx::query(&sql).bind(file_uuid).bind(trace_id).bind(name);