From d6499ce9f64d6f71d389e2ad32b112147a2f162a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 24 Feb 2023 12:05:26 +0300 Subject: auth: resources: Fix queries loading resources data. --- gn3/auth/authorisation/resources/models.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gn3/auth/authorisation/resources/models.py b/gn3/auth/authorisation/resources/models.py index 40e12ba..d3023ac 100644 --- a/gn3/auth/authorisation/resources/models.py +++ b/gn3/auth/authorisation/resources/models.py @@ -207,6 +207,7 @@ def attach_resource_data(cursor: db.DbCursor, resource: Resource) -> Resource: dict(data_row) for data_row in resource_data_function[category.resource_category_key]( cursor, resource.resource_id)) + print(f"DATA ROWS: {data_rows}") return Resource( resource.group, resource.resource_id, resource.resource_name, resource.resource_category, resource.public, data_rows) @@ -216,7 +217,9 @@ def mrna_resource_data( """Fetch data linked to a mRNA resource""" cursor.execute( "SELECT * FROM mrna_resources AS mr INNER JOIN linked_group_data AS lgd" - " ON mr.dataset_id=lgd.dataset_or_trait_id WHERE mr.resource_id=?", + " ON (mr.dataset_id=lgd.dataset_or_trait_id " + "AND mr.dataset_type=lgd.dataset_type) " + "WHERE mr.resource_id=?", (str(resource_id),)) return cursor.fetchall() @@ -226,7 +229,8 @@ def genotype_resource_data( cursor.execute( "SELECT * FROM genotype_resources AS gr " "INNER JOIN linked_group_data AS lgd " - "ON gr.trait_id=lgd.dataset_or_trait_id " + "ON (gr.trait_id=lgd.dataset_or_trait_id " + "AND gr.dataset_type=lgd.dataset_type) " "WHERE gr.resource_id=?", (str(resource_id),)) return cursor.fetchall() @@ -237,7 +241,8 @@ def phenotype_resource_data( cursor.execute( "SELECT * FROM phenotype_resources AS pr " "INNER JOIN linked_group_data AS lgd " - "ON pr.trait_id=lgd.dataset_or_trait_id " + "ON (pr.trait_id=lgd.dataset_or_trait_id " + "AND pr.dataset_type=lgd.dataset_type) " "WHERE pr.resource_id=?", (str(resource_id),)) return cursor.fetchall() -- cgit v1.2.3