Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
fix: Handle zero length arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Dec 20, 2023
1 parent ca1a9aa commit 30d521f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tm_admin/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def writeAllData(self,
# bar.next()
for key, val in record.items():
columns.append(key)
print(f"FIXME: {key} = {self.config[key]}")
# print(f"FIXME: {key} = {self.config[key]}")
# Booleans need to set 't' or 'f' for postgres.
if self.config[key]['datatype'] == 'bool':
if val:
Expand Down Expand Up @@ -207,9 +207,8 @@ def writeAllData(self,
values += f"}}'::{self.config[key]['datatype'].lower()}[], "
continue
else:
# The TM database has a bug, a 0 usually means tthere is no value,
# The TM database has a bug, a 0 usually means there is no value,
# so we bump it up to pick the first entry in the enum.
print(key, val)
if val is None:
values += f"'{{}}', "
continue
Expand All @@ -223,6 +222,9 @@ def writeAllData(self,
else:
if self.config[key]['array']:
if val is not None:
if len(val) == 0:
values += "NULL, "
continue
values += "ARRAY["
for item in val:
esc = item.replace("'", "")
Expand Down

0 comments on commit 30d521f

Please sign in to comment.