From d338b5bab3200a44e37581ef36946d7f31809129 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:38:32 -0700 Subject: [PATCH] Auto-update: Thu Jul 25 09:38:32 PDT 2024 --- sijapi/classes.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sijapi/classes.py b/sijapi/classes.py index 6e25578..484d4dc 100644 --- a/sijapi/classes.py +++ b/sijapi/classes.py @@ -398,14 +398,20 @@ class APIConfig(BaseModel): """, last_synced_version, source_pool_entry['ts_id']) for change in changes: - columns = change.keys() + # Convert change.keys() to a list + columns = list(change.keys()) values = [change[col] for col in columns] - await dest_conn.execute(f""" + + # Construct the SQL query + insert_query = f""" INSERT INTO "{table_name}" ({', '.join(columns)}) VALUES ({', '.join(f'${i+1}' for i in range(len(columns)))}) ON CONFLICT (id) DO UPDATE SET {', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col != 'id')} - """, *values) + """ + + # Execute the query + await dest_conn.execute(insert_query, *values) if changes: await self.update_sync_status(table_name, source_pool_entry['ts_id'], changes[-1]['version'])