1111
1212class RouteBase (SQLModel ):
1313 """Shared fields between table and API models"""
14- name : str = Field (default = "" , min_length = 1 , max_length = 255 ) # can change this later
15- notes : str = Field (default = "" , max_length = 1000 ) # can change this later
14+
15+ name : str = Field (default = "" , min_length = 1 , max_length = 255 ) # can change this later
16+ notes : str = Field (default = "" , max_length = 1000 ) # can change this later
1617 length : float = Field (ge = 0.0 ) # in km, must be non-negative
1718
1819
1920class Route (RouteBase , BaseModel , table = True ):
2021 """Database table model for Routes
21-
22+
2223 Note: Routes are immutable once created
2324 """
2425
2526 __tablename__ = "routes"
2627
27- route_id : UUID = Field (
28- default = uuid4 ,
29- primary_key = True ,
30- nullable = False
31- )
28+ route_id : UUID = Field (default = uuid4 , primary_key = True , nullable = False )
3229
3330 # Relationship to route stops
3431 route_stops : list ["RouteStop" ] = Relationship (
35- back_populates = "route" ,
36- sa_relationship_kwargs = {"cascade" : "all, delete-orphan" }
32+ back_populates = "route" , sa_relationship_kwargs = {"cascade" : "all, delete-orphan" }
3733 )
3834
3935
@@ -51,11 +47,11 @@ class RouteRead(RouteBase):
5147
5248class RouteUpdate (SQLModel ):
5349 """Update request model - all optional
54-
50+
5551 Note: Routes are meant to be immutable, but this allows updates if needed
5652 """
5753
5854 route_group_id : UUID | None = None
5955 name : str | None = None
6056 notes : str | None = None
61- length : float | None = None
57+ length : float | None = None
0 commit comments