Skip to content

Commit

Permalink
Merge pull request #47 from lsst-dm/tickets/DM-46556-alembic-hotfix
Browse files Browse the repository at this point in the history
Fix incorrect primary keys in pqserver insert
  • Loading branch information
bbrondel authored Oct 18, 2024
2 parents b5b3898 + 3c50229 commit 3d20e0c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions python/lsst/consdb/pqserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,13 @@ def insert(
# If needed, cross-reference day_obs and seq_num from the exposure table.
if "day_obs" in table_obj.columns and "seq_num" in table_obj.columns:
if "day_obs" not in valdict or "seq_num" not in valdict:
day_obs, seq_num = instrument_tables.get_day_obs_and_seq_num(instrument_l, obs_id)

primary_key = obs_id
for primary_key_name in ("obs_id", "exposure_id", "visit_id"):
if primary_key_name in valdict:
primary_key = valdict["primary_key_name"]

day_obs, seq_num = instrument_tables.get_day_obs_and_seq_num(instrument_l, primary_key)
if "day_obs" not in valdict:
valdict["day_obs"] = day_obs
if "seq_num" not in valdict:
Expand Down Expand Up @@ -853,7 +859,12 @@ def insert_multiple(
# exposure table.
if "day_obs" in table_obj.columns and "seq_num" in table_obj.columns:
if "day_obs" not in valdict or "seq_num" not in valdict:
day_obs, seq_num = instrument_tables.get_day_obs_and_seq_num(instrument_l, obs_id)
primary_key = obs_id
for primary_key_name in ("obs_id", "exposure_id", "visit_id"):
if primary_key_name in valdict:
primary_key = valdict["primary_key_name"]

day_obs, seq_num = instrument_tables.get_day_obs_and_seq_num(instrument_l, primary_key)
if "day_obs" not in valdict:
valdict["day_obs"] = day_obs
if "seq_num" not in valdict:
Expand Down

0 comments on commit 3d20e0c

Please sign in to comment.