refactor: update repository mixin

This commit is contained in:
2025-09-07 21:28:06 +04:00
parent 7a76da4058
commit 67634836dc
5 changed files with 42 additions and 26 deletions

View File

@ -1,5 +1,3 @@
from typing import overload
from sqlalchemy import Select
from sqlalchemy.orm import selectinload
@ -10,6 +8,7 @@ from repositories.mixins import (
RepCreateMixin,
GetByIdMixin,
GetAllMixin,
RepUpdateMixin,
)
from schemas.project import CreateProjectSchema, UpdateProjectSchema
@ -19,6 +18,7 @@ class ProjectRepository(
GetAllMixin[Project],
RepDeleteMixin[Project],
RepCreateMixin[Project, CreateProjectSchema],
RepUpdateMixin[Project, UpdateProjectSchema],
GetByIdMixin[Project],
):
entity_class = Project
@ -30,9 +30,4 @@ class ProjectRepository(
return stmt.options(selectinload(Project.boards))
async def update(self, project: Project, data: UpdateProjectSchema) -> Project:
project.name = data.name if data.name else project.name
self.session.add(project)
await self.session.commit()
await self.session.refresh(project)
return project
return await self._apply_update_data_to_model(project, data, True)