diff --git a/api/app/application/appointment_types_repository.py b/api/app/application/appointment_types_repository.py index 4ac213d..21659ae 100644 --- a/api/app/application/appointment_types_repository.py +++ b/api/app/application/appointment_types_repository.py @@ -16,6 +16,6 @@ class AppointmentTypesRepository: return result.scalars().all() async def get_by_id(self, appointment_type_id: int) -> Optional[AppointmentType]: - stmt = select(AppointmentType).filter(AppointmentType.id == appointment_type_id) + stmt = select(AppointmentType).filter_by(id=appointment_type_id) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/appointments_repository.py b/api/app/application/appointments_repository.py index fee24fb..675d8ec 100644 --- a/api/app/application/appointments_repository.py +++ b/api/app/application/appointments_repository.py @@ -28,7 +28,7 @@ class AppointmentsRepository: .options(joinedload(Appointment.type)) .options(joinedload(Appointment.patient)) .options(joinedload(Appointment.doctor)) - .filter(Appointment.doctor_id == doctor_id) + .filter_by(doctor_id=doctor_id) .order_by(desc(Appointment.appointment_datetime)) ) result = await self.db.execute(stmt) @@ -40,7 +40,7 @@ class AppointmentsRepository: .options(joinedload(Appointment.type)) .options(joinedload(Appointment.patient)) .options(joinedload(Appointment.doctor)) - .filter(Appointment.patient_id == patient_id) + .filter_by(patient_id=patient_id) .order_by(desc(Appointment.appointment_datetime)) ) result = await self.db.execute(stmt) @@ -52,7 +52,7 @@ class AppointmentsRepository: .options(joinedload(Appointment.type)) .options(joinedload(Appointment.patient)) .options(joinedload(Appointment.doctor)) - .filter(Appointment.id == appointment_id) + .filter_by(id=appointment_id) ) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/lens_issues_repository.py b/api/app/application/lens_issues_repository.py index 787d973..b93633a 100644 --- a/api/app/application/lens_issues_repository.py +++ b/api/app/application/lens_issues_repository.py @@ -23,7 +23,7 @@ class LensIssuesRepository: return result.scalars().all() async def get_by_id(self, lens_issue_id: int) -> Optional[LensIssue]: - stmt = select(LensIssue).filter(LensIssue.id == lens_issue_id) + stmt = select(LensIssue).filter_by(id=lens_issue_id) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/lens_types_repository.py b/api/app/application/lens_types_repository.py index 3edf2c5..17e6db4 100644 --- a/api/app/application/lens_types_repository.py +++ b/api/app/application/lens_types_repository.py @@ -16,7 +16,7 @@ class LensTypesRepository: return result.scalars().all() async def get_by_id(self, lens_type_id: int) -> Optional[LensType]: - stmt = select(LensType).filter(LensType.id == lens_type_id) + stmt = select(LensType).filter_by(id=lens_type_id) result = await self.db.execute(stmt) return result.scalars().first() @@ -32,7 +32,7 @@ class LensTypesRepository: return lens_type async def delete(self, lens_type_id: int) -> Row[LensType] | RowMapping | None: - stmt = select(LensType).filter(LensType.id == lens_type_id) + stmt = select(LensType).filter_by(id=lens_type_id) result = await self.db.execute(stmt) lens_type = result.scalars().first() diff --git a/api/app/application/lenses_repository.py b/api/app/application/lenses_repository.py index f8f14ae..718d1ad 100644 --- a/api/app/application/lenses_repository.py +++ b/api/app/application/lenses_repository.py @@ -1,6 +1,6 @@ from typing import Sequence, Optional -from sqlalchemy import select +from sqlalchemy import select, desc from sqlalchemy.ext.asyncio import AsyncSession from app.domain.models import Lens @@ -11,17 +11,17 @@ class LensesRepository: self.db = db async def get_all(self) -> Sequence[Lens]: - stmt = select(Lens) + stmt = select(Lens).order_by(Lens.id) result = await self.db.execute(stmt) return result.scalars().all() async def get_all_not_issued(self) -> Sequence[Lens]: - stmt = select(Lens).filter(Lens.issued == False) + stmt = select(Lens).filter_by(issued=False).order_by(desc(Lens.id)) result = await self.db.execute(stmt) return result.scalars().all() async def get_by_id(self, lens_id: int) -> Optional[Lens]: - stmt = select(Lens).filter(Lens.id == lens_id) + stmt = select(Lens).filter_by(id=lens_id) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/patients_repository.py b/api/app/application/patients_repository.py index 3d823a5..a1ae985 100644 --- a/api/app/application/patients_repository.py +++ b/api/app/application/patients_repository.py @@ -16,7 +16,7 @@ class PatientsRepository: return result.scalars().all() async def get_by_id(self, patient_id: int) -> Optional[Patient]: - stmt = select(Patient).filter(Patient.id == patient_id) + stmt = select(Patient).filter_by(id=patient_id) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/roles_repository.py b/api/app/application/roles_repository.py index d91cad9..0075c42 100644 --- a/api/app/application/roles_repository.py +++ b/api/app/application/roles_repository.py @@ -16,6 +16,6 @@ class RolesRepository: return result.scalars().all() async def get_by_id(self, role_id: int) -> Optional[Role]: - stmt = select(Role).filter(Role.id == role_id) + stmt = select(Role).filter_by(id=role_id) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/scheduled_appointments_repository.py b/api/app/application/scheduled_appointments_repository.py index 6692e84..40a1084 100644 --- a/api/app/application/scheduled_appointments_repository.py +++ b/api/app/application/scheduled_appointments_repository.py @@ -28,7 +28,7 @@ class ScheduledAppointmentsRepository: .options(joinedload(ScheduledAppointment.type)) .options(joinedload(ScheduledAppointment.patient)) .options(joinedload(ScheduledAppointment.doctor)) - .filter(ScheduledAppointment.doctor_id == doctor_id) + .filter_by(doctor_id=doctor_id) .order_by(desc(ScheduledAppointment.scheduled_datetime)) ) result = await self.db.execute(stmt) @@ -40,7 +40,7 @@ class ScheduledAppointmentsRepository: .options(joinedload(ScheduledAppointment.type)) .options(joinedload(ScheduledAppointment.patient)) .options(joinedload(ScheduledAppointment.doctor)) - .filter(ScheduledAppointment.patient_id == patient_id) + .filter_by(patient_id=patient_id) .order_by(desc(ScheduledAppointment.scheduled_datetime)) ) result = await self.db.execute(stmt) @@ -52,7 +52,7 @@ class ScheduledAppointmentsRepository: .options(joinedload(ScheduledAppointment.type)) .options(joinedload(ScheduledAppointment.patient)) .options(joinedload(ScheduledAppointment.doctor)) - .filter(ScheduledAppointment.id == scheduled_appointment_id) + .filter_by(id=scheduled_appointment_id) ) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/set_content_repository.py b/api/app/application/set_content_repository.py index 098c5c1..09b2aa6 100644 --- a/api/app/application/set_content_repository.py +++ b/api/app/application/set_content_repository.py @@ -16,12 +16,12 @@ class SetContentRepository: return result.scalars().all() async def get_by_id(self, set_content_id: int) -> Optional[SetContent]: - stmt = select(SetContent).filter(SetContent.id == set_content_id) + stmt = select(SetContent).filter_by(id=set_content_id) result = await self.db.execute(stmt) return result.scalars().first() async def get_by_set_id(self, set_id: int) -> Sequence[SetContent]: - stmt = select(SetContent).filter(SetContent.set_id == set_id) + stmt = select(SetContent).filter_by(set_id=set_id) result = await self.db.execute(stmt) return result.scalars().all() diff --git a/api/app/application/sets_repository.py b/api/app/application/sets_repository.py index db3451f..6aea62f 100644 --- a/api/app/application/sets_repository.py +++ b/api/app/application/sets_repository.py @@ -16,7 +16,7 @@ class SetsRepository: return result.scalars().all() async def get_by_id(self, set_id: int) -> Optional[Set]: - stmt = select(Set).filter(Set.id == set_id) + stmt = select(Set).filter_by(id=set_id) result = await self.db.execute(stmt) return result.scalars().first() diff --git a/api/app/application/users_repository.py b/api/app/application/users_repository.py index c982642..18d6696 100644 --- a/api/app/application/users_repository.py +++ b/api/app/application/users_repository.py @@ -17,14 +17,14 @@ class UsersRepository: return result.scalars().all() async def get_by_id(self, user_id: int) -> Optional[User]: - stmt = select(User).filter(User.id == user_id) + stmt = select(User).filter_by(id=user_id) result = await self.db.execute(stmt) return result.scalars().first() async def get_by_login(self, user_login: str) -> Optional[User]: stmt = ( select(User) - .filter(User.login == user_login) + .filter_by(login=user_login) .options(joinedload(User.role)) ) result = await self.db.execute(stmt) @@ -33,7 +33,7 @@ class UsersRepository: async def get_by_id_with_role(self, user_id: int) -> Optional[User]: stmt = ( select(User) - .filter(User.id == user_id) + .filter_by(id=user_id) .options(joinedload(User.role)) ) result = await self.db.execute(stmt)