diff options
author | BonfaceKilz | 2022-03-01 16:31:07 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-03-12 15:33:09 +0300 |
commit | 4b156c19afbe91f9feb5a65e263b771fbf6502cc (patch) | |
tree | d765c01e1e6ca9b629a455fd77766b5a4e75e10d /gn3/db | |
parent | b6ecd0888ccf51b1dd2bfcbbbc4e03b1c5a92699 (diff) | |
download | genenetwork3-4b156c19afbe91f9feb5a65e263b771fbf6502cc.tar.gz |
Fetch id's separately for the insertion edge-case
* gn3/db/sample_data (get_sample_data_ids): Add an extra condition that caters
for inserts: during inserts, joins won't work when fetching the strain_id,
publishdata_id, and strain_name. In this case, just create 2 separate queries
to do that work.
Diffstat (limited to 'gn3/db')
-rw-r--r-- | gn3/db/sample_data.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gn3/db/sample_data.py b/gn3/db/sample_data.py index a410978..e3e1676 100644 --- a/gn3/db/sample_data.py +++ b/gn3/db/sample_data.py @@ -68,6 +68,15 @@ def get_sample_data_ids(conn: Any, publishxref_id: int, (publishxref_id, phenotype_id, strain_name)) if _result := cursor.fetchone(): strain_id, publishdata_id, inbredset_id = _result + if not all([strain_id, publishdata_id, inbredset_id]): + # Applies for data to be inserted: + cursor.execute("SELECT DataId, InbredSetId FROM PublishXRef " + "WHERE Id = %s AND PhenotypeId = %s", + (publishxref_id, phenotype_id)) + publishdata_id, inbredset_id = cursor.fetchone() + cursor.execute("SELECT Id FROM Strain WHERE Name = %s", + (strain_name,)) + strain_id = cursor.fetchone() return (strain_id, publishdata_id, inbredset_id) |