From 6e63d1b962b1b0b5a8420550d4d37473c52d368a Mon Sep 17 00:00:00 2001 From: VincentCauchois Date: Mon, 27 May 2024 14:16:01 +0200 Subject: [PATCH] fix(mtd): make `sync_af` return actual af model and not int Modify the function `sync_af` so that it returns the actual acquisition framework ; an instance of the model `TAcquisitionFramework` ; rather than an integer. This, in turn, fixes the function `process_af_and_ds` and fixes MTD synchronization. --- backend/geonature/core/gn_meta/mtd/mtd_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/geonature/core/gn_meta/mtd/mtd_utils.py b/backend/geonature/core/gn_meta/mtd/mtd_utils.py index ed18813c7b..34b6795108 100644 --- a/backend/geonature/core/gn_meta/mtd/mtd_utils.py +++ b/backend/geonature/core/gn_meta/mtd/mtd_utils.py @@ -140,8 +140,12 @@ def sync_af(af): .on_conflict_do_nothing(index_elements=["unique_acquisition_framework_id"]) .returning(TAcquisitionFramework) ) + DB.session.execute(statement) - return DB.session.scalar(statement) + acquisition_framework = DB.session.scalars( + select(TAcquisitionFramework).filter_by(unique_acquisition_framework_id=af_uuid) + ) + return acquisition_framework def add_or_update_organism(uuid, nom, email):