From 2fed2adb62fd720d203dd134d8db9dbd2ebfe7ac Mon Sep 17 00:00:00 2001 From: sundandan Date: Tue, 15 Dec 2020 10:36:01 +0800 Subject: [PATCH] [sonic-telemetry] Fix the bug that the old fvs may be overriden in makeJSON. Signed-off-by: sundandan --- sonic_data_client/db_client.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sonic_data_client/db_client.go b/sonic_data_client/db_client.go index fdafe5976..5ba187b4b 100644 --- a/sonic_data_client/db_client.go +++ b/sonic_data_client/db_client.go @@ -500,6 +500,25 @@ func makeJSON_redis(msi *map[string]interface{}, key *string, op *string, mfv ma } fp := map[string]interface{}{} + + if key == nil { + if (*msi)[*op] != nil { + fp = (*msi)[*op].(map[string]interface{}) + } + } else if op == nil { + if (*msi)[*key] != nil { + fp = (*msi)[*key].(map[string]interface{}) + } + } else { + of_old := map[string]interface{}{} + if (*msi)[*key] != nil { + of_old = (*msi)[*key].(map[string]interface{}) + if of_old[*op] != nil { + fp = of_old[*op].(map[string]interface{}) + } + } + } + for f, v := range mfv { fp[f] = v }