Skip to content

Commit

Permalink
fix for issue 3053. Added check to determine if variable meta is a di…
Browse files Browse the repository at this point in the history
…ct (VOLTTRON#3054)

* fix for issue 3053. Added check to determin if variable meta is a dict

* Fixes for VOLTTRON#3053. Changed dict check to use isinstance

* refactored solution for readability

* Update postgresqlfuncts.py

Make for loop more pretty
  • Loading branch information
ntenney authored Nov 2, 2022
1 parent e8ac5f5 commit 7880c9a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion volttron/platform/dbutils/postgresqlfuncts.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,17 @@ def get_topic_meta_map(self):
'SELECT topic_id, metadata '
'FROM {}').format(Identifier(self.meta_table))
rows = self.select(query)
meta_map = {tid: jsonapi.loads(meta) if meta else None for tid, meta in rows}

meta_map = {}
for tid, meta in rows:
if meta:
if isinstance(meta, dict):
meta_map[tid] = meta
else:
meta_map[tid] = jsonapi.loads(meta)
else:
meta_map[tid] = None

return meta_map

def get_agg_topics(self):
Expand Down

0 comments on commit 7880c9a

Please sign in to comment.