diff --git a/genotype_api/database/crud/update.py b/genotype_api/database/crud/update.py index 0a12cfa..74ac4ba 100644 --- a/genotype_api/database/crud/update.py +++ b/genotype_api/database/crud/update.py @@ -31,10 +31,16 @@ 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).selectinload(Analysis.genotypes)) + .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()