Skip to content

Commit

Permalink
fix(insert): only fetch state ID when inserting dataset
Browse files Browse the repository at this point in the history
Instead of fetching the hole state, only fetch ID.

Fixes chime-experiment/comet/issues/74
  • Loading branch information
nritsche committed Jan 21, 2020
1 parent d54bae5 commit baffb26
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion chimedb/dataset/insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def insert_dataset(ds_id, base_dset, is_root, state, time):
DatasetState.DoesNotExist
If the state attached to the dataset is not found in the database.
"""
state = DatasetState.get(DatasetState.id == state)
try:
Dataset.get(Dataset.id == ds_id)
except Dataset.DoesNotExist:
if base_dset:
Dataset.get(Dataset.id == base_dset)
state = DatasetState.select(DatasetState.id).get(DatasetState.id == state)
Dataset.get_or_create(
id=ds_id, state=state, root=is_root, time=time, base_dset=base_dset,
)

0 comments on commit baffb26

Please sign in to comment.