From dd855828d0b878103468ae49046ebba04b6a779f Mon Sep 17 00:00:00 2001 From: abduznik <85239936+abduznik@users.noreply.github.com> Date: Mon, 29 Jun 2026 07:04:51 +0300 Subject: [PATCH] fix: resubmit project with same name no longer corrupts skill linkage When resubmitting a major project with the same name as a previous submission, the re-query filtered by (name, uid) returned the OLDEST matching project instead of the one just created. This caused: 1. Skills to be linked to the wrong (old) project 2. A PRIMARY KEY collision on major_project_skills when the same skills already existed for that old project 3. The new project to be left orphaned with zero skills Fix: query by project.id (the known primary key) instead of by (name, uid). After db.session.commit(), SQLAlchemy has populated project.id with the auto-generated PK, so we can identify the correct project unambiguously. Test: isolated testbench using SQLAlchemy with the exact production model definitions confirms: - Bug: re-query by (name, uid) returns id=1 when id=2 is expected - Fix: re-query by project.id returns the correct project every time - Each resubmission correctly links skills to its own project --- conditional/blueprints/major_project_submission.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/conditional/blueprints/major_project_submission.py b/conditional/blueprints/major_project_submission.py index 5ef21cc1..a400a5f4 100644 --- a/conditional/blueprints/major_project_submission.py +++ b/conditional/blueprints/major_project_submission.py @@ -122,10 +122,7 @@ def submit_major_project(user_dict=None): db.session.add(project) db.session.commit() - project = MajorProject.query.filter( - MajorProject.name == name, - MajorProject.uid == user_id - ).first() + project = MajorProject.query.get(project.id) skills_list: list = list(filter(lambda x: x != 'None', skills))