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

Commit

Permalink
fix: Indent executing SQL so it works for all the records
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Mar 7, 2024
1 parent a790874 commit 728b4da
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tm_admin/pgsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,20 @@ async def insertRecords(self,
else:
data[key] = value

keys = str(list(data.keys())).replace("'", "")[1:-1]
# This is a bit ugly. When passing a geometry we need to get rid of the
# double quote around this value.
values = str(list(data.values()))[1:-1]
# FIXME: dealing with quoting between python and postgres is a hassle
foo = values.replace('"X', "").replace('X"', "")
# print(f"1: {foo}")
foo = foo.replace("'X", "").replace("X'", "")
# print(f"2: {foo}")
sql = f"INSERT INTO {self.table}({keys}) VALUES({foo}) RETURNING id"
# print(sql)
result = await self.execute(sql)
# print(result)
keys = str(list(data.keys())).replace("'", "")[1:-1]
# This is a bit ugly. When passing a geometry we need to get rid of the
# double quote around this value.
values = str(list(data.values()))[1:-1]
# FIXME: dealing with quoting between python and postgres is a hassle
foo = values.replace('"X', "").replace('X"', "")
# print(f"1: {foo}")
foo = foo.replace("'X", "").replace("X'", "")
# print(f"2: {foo}")
sql = f"INSERT INTO {self.table}({keys}) VALUES({foo}) RETURNING id"
# print(sql)
result = await self.execute(sql)
# print(result)

if len(result) > 0:
return result[0]['id']
else:
Expand Down

0 comments on commit 728b4da

Please sign in to comment.