fix(go): preserve sparse realtime location fields
This commit is contained in:
@@ -223,6 +223,23 @@ func TestRealtimeUpsertsDoNotOverwriteWithOlderEventTime(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealtimeLocationUpsertKeepsExistingSparseFieldsWhenMQTTOnlySendsCoordinates(t *testing.T) {
|
||||
for _, column := range []string{
|
||||
"speed_kmh",
|
||||
"total_mileage_km",
|
||||
"soc_percent",
|
||||
"altitude_m",
|
||||
"direction_deg",
|
||||
"alarm_flag",
|
||||
"status_flag",
|
||||
} {
|
||||
want := column + " = IF(VALUES(event_time) IS NOT NULL AND (vehicle_realtime_location.event_time IS NULL OR VALUES(event_time) >= vehicle_realtime_location.event_time), COALESCE(VALUES(" + column + "), " + column + "), " + column + ")"
|
||||
if !strings.Contains(upsertRealtimeLocationSQL, want) {
|
||||
t.Fatalf("location upsert should keep existing %s when incoming sparse MQTT frame omits it; missing:\n%s\nin:\n%s", column, want, upsertRealtimeLocationSQL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSnapshotWriterBackfillsPlateFromBindingByVIN(t *testing.T) {
|
||||
exec := &recordingSnapshotExec{}
|
||||
resolver := &recordingPlateResolver{plate: "沪A12345"}
|
||||
|
||||
Reference in New Issue
Block a user