diff options
author | Frederick Muriuki Muriithi | 2021-12-09 06:25:10 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2021-12-09 09:19:57 +0300 |
commit | c5f78421c50dc7c9e4801ad7bf9583674c29e1ba (patch) | |
tree | 46bde68b01a1d56117516d51b39143dbee4b07c8 /gn3/db | |
parent | dd55b1376cbff6c9870b3173f8dc6207505a57c6 (diff) | |
download | genenetwork3-c5f78421c50dc7c9e4801ad7bf9583674c29e1ba.tar.gz |
Prevent error on no result. Fix indexing
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
* If the dataset name is not found, don't cause an exception, instead, return
the provided search name.
* Use the correct inner object
Diffstat (limited to 'gn3/db')
-rw-r--r-- | gn3/db/datasets.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py index e4c779a..c50e148 100644 --- a/gn3/db/datasets.py +++ b/gn3/db/datasets.py @@ -26,10 +26,13 @@ def retrieve_probeset_trait_dataset_name( "threshold": threshold, "name": name }) - return dict(zip( - ["dataset_id", "dataset_name", "dataset_fullname", - "dataset_shortname", "dataset_datascale"], - cursor.fetchone())) + res = cursor.fetchone() + if res: + return dict(zip( + ["dataset_id", "dataset_name", "dataset_fullname", + "dataset_shortname", "dataset_datascale"], + res)) + return {"dataset_id": None, "dataset_name": name, "dataset_fullname": name} def retrieve_publish_trait_dataset_name( threshold: int, name: str, connection: Any): |