refactor: update repository mixin
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user