Skip to content

Commit

Permalink
Fix pk in tg_p1 curves
Browse files Browse the repository at this point in the history
  • Loading branch information
oriolpiera committed Jan 15, 2024
1 parent cc9950a commit 028a3c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cchloader/backends/timescaledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ def insert_cch_batch_chunk(self, collection, batch):
fields_to_update.append('write_date=EXCLUDED.create_date')
fields_to_update.append('write_uid=EXCLUDED.create_uid')

sql = "INSERT INTO {} ({}) VALUES %s ON CONFLICT (name, utc_timestamp) DO UPDATE SET {};".format(
on_conflict = 'name, utc_timestamp'
if collection == 'tg_p1':
on_conflict = 'name, utc_timestamp, type'
sql = "INSERT INTO {} ({}) VALUES %s ON CONFLICT ({}) DO UPDATE SET {};".format(
collection,
','.join(field_names),
on_conflict,
', '.join(fields_to_update)
)

Expand Down

0 comments on commit 028a3c5

Please sign in to comment.