about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--uploader/phenotypes/models.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 3e749c0..eb926d8 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -327,9 +327,12 @@ def save_phenotypes_data(
 ) -> tuple[dict, ...]:
     """Save new phenotypes data into the database."""
     _table_details = {
-        "PublishData": {"table": "PublishData", "valueCol": "value"},
-        "PublishSE": {"table": "PublishSE", "valueCol": "error"},
-        "NStrain": {"table": "PublishData", "valueCol": "count"}
+        "PublishData": {
+            "table": "PublishData", "valueCol": "value", "DataIdCol": "Id"},
+        "PublishSE": {
+            "table": "PublishSE", "valueCol": "error", "DataIdCol": "DataId"},
+        "NStrain": {
+            "table": "PublishData", "valueCol": "count", "DataIdCol": "DataId"}
     }[table]
     saved_data = tuple()
     with conn.cursor(cursorclass=DictCursor) as cursor:
@@ -341,7 +344,7 @@ def save_phenotypes_data(
 
             cursor.executemany(
                 (f"INSERT INTO {_table_details['table']}"
-                 f"(Id, StrainId, {_table_details['valueCol']}) "
+                 f"({_table_details['DataIdCol']}, StrainId, {_table_details['valueCol']}) "
                  "VALUES "
                  f"(%(data_id)s, %(sample_id)s, %({_table_details['valueCol']})s) "
                  "RETURNING *"),