From 38227b8e482ea10f8bb111a1a90f22f8f019e2ab Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 19 Mar 2024 04:48:43 +0300 Subject: Query by `Id` rather than `ProbeFreezeId` Previously `ProbeFreezeId` was set as 1 more than the largest `Id` value found, which might not end up being the same as the incremented Id. This commit, thus, queries by `Id` which is more robust, and does an actual update for the `ProbeFreezeId` column to make it same value as `Id`. --- qc_app/dbinsert.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qc_app') diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py index f36651f..150127d 100644 --- a/qc_app/dbinsert.py +++ b/qc_app/dbinsert.py @@ -171,6 +171,10 @@ def create_study(): "ShortName, CreateTime, InbredSetId) " "VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)") cursor.execute(query, values) + lastrowid = cursor.lastrowid + cursor.execute( + "UPDATE ProbeFreeze SET ProbeFreezeId=%s WHERE Id=%s", + (lastrowid, lastrowid)) flash("Study created successfully", "alert-success") return render_template( "continue_from_create_study.html", @@ -294,7 +298,7 @@ def study_by_id(studyid:int) -> Union[dict, None]: with database_connection() as conn: with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( - "SELECT * FROM ProbeFreeze WHERE ProbeFreezeId=%s", + "SELECT * FROM ProbeFreeze WHERE Id=%s", (studyid,)) return cursor.fetchone() -- cgit v1.2.3