Skip to content

Commit

Permalink
Enable upsert of consensus_genome records with ON CONFLICT clause
Browse files Browse the repository at this point in the history
The upsert_genome function was only performing inserts. Adding ON CONFLICT clause to perform a "non-updating" update and return the existing record id.
  • Loading branch information
davereinhart committed Sep 16, 2024
1 parent 5929a34 commit e306ec1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/seattleflu/id3c/cli/command/etl/clinical.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ def upsert_genome(db: DatabaseSession, sample: MinimalSampleRecord, organism: Or
insert into warehouse.consensus_genome (sample_id, organism_id)
values (%(sample_id)s, %(organism_id)s)
on conflict (sample_id, organism_id) where sequence_read_set_id is null do update
set sample_id = excluded.sample_id,
organism_id = excluded.organism_id
returning consensus_genome_id as id, sample_id, organism_id
""", data)

Expand Down

0 comments on commit e306ec1

Please sign in to comment.