From aa566bfa885564d59a444a6680226b8a317d31eb Mon Sep 17 00:00:00 2001 From: ahdamin Date: Fri, 13 Dec 2024 14:34:27 +0100 Subject: [PATCH] Add analyses loading to query --- genotype_api/database/crud/update.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/genotype_api/database/crud/update.py b/genotype_api/database/crud/update.py index 0a12cfa..413f863 100644 --- a/genotype_api/database/crud/update.py +++ b/genotype_api/database/crud/update.py @@ -31,10 +31,14 @@ async def refresh_sample_status( return sample async def update_sample_comment(self, sample_id: str, comment: str) -> Sample: - query: Query = select(Sample).distinct().filter(Sample.id == sample_id) + query: Query = ( + select(Sample).options(selectinload(Sample.analyses)).filter(Sample.id == sample_id) + ) sample: Sample = await self.fetch_one_or_none(query) + if not sample: raise SampleNotFoundError + sample.comment = comment self.session.add(sample) await self.session.commit()