From 0f8772f572ad86e41d1dccda99e4bb1d4551b51a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 30 May 2025 13:11:33 -0500 Subject: Use full table names rather than aliases Using aliases leads to errors when you have to use table locking to prevent data corruption. This commit updates queries to use the full table names rather than aliases, in order to prevent such troubles. --- uploader/samples/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'uploader/samples') diff --git a/uploader/samples/models.py b/uploader/samples/models.py index d7d5384..b419d61 100644 --- a/uploader/samples/models.py +++ b/uploader/samples/models.py @@ -15,11 +15,11 @@ def samples_by_species_and_population( """Fetch the samples by their species and population.""" with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( - "SELECT iset.InbredSetId, s.* FROM InbredSet AS iset " - "INNER JOIN StrainXRef AS sxr ON iset.InbredSetId=sxr.InbredSetId " - "INNER JOIN Strain AS s ON sxr.StrainId=s.Id " - "WHERE s.SpeciesId=%(species_id)s " - "AND iset.InbredSetId=%(population_id)s", + "SELECT InbredSet.InbredSetId, Strain.* FROM InbredSet " + "INNER JOIN StrainXRef ON InbredSet.InbredSetId=StrainXRef.InbredSetId " + "INNER JOIN Strain ON StrainXRef.StrainId=Strain.Id " + "WHERE Strain.SpeciesId=%(species_id)s " + "AND InbredSet.InbredSetId=%(population_id)s", {"species_id": species_id, "population_id": population_id}) return tuple(cursor.fetchall()) -- cgit v1.2.3