Fix type annotation for location_id; change from Optional[str] to Optional[int] for correct database mapping
This commit is contained in:
parent
8162038f40
commit
04d262ae26
2 changed files with 5 additions and 4 deletions
|
@ -17,7 +17,7 @@ class User(db.Model):
|
||||||
active: Mapped[Optional[bool]] = mapped_column("Active", Boolean, server_default=text('((0))'))
|
active: Mapped[Optional[bool]] = mapped_column("Active", Boolean, server_default=text('((0))'))
|
||||||
last_name: Mapped[Optional[str]] = mapped_column("Last", Unicode(255), nullable=True)
|
last_name: Mapped[Optional[str]] = mapped_column("Last", Unicode(255), nullable=True)
|
||||||
first_name: Mapped[Optional[str]] = mapped_column("First", Unicode(255), nullable=True)
|
first_name: Mapped[Optional[str]] = mapped_column("First", Unicode(255), nullable=True)
|
||||||
location_id: Mapped[Optional[str]] = mapped_column(ForeignKey("Rooms.ID"), nullable=True)
|
location_id: Mapped[Optional[int]] = mapped_column(ForeignKey("Rooms.ID"), nullable=True)
|
||||||
supervisor_id: Mapped[Optional[int]] = mapped_column("Supervisor", Integer, ForeignKey("Users.ID"))
|
supervisor_id: Mapped[Optional[int]] = mapped_column("Supervisor", Integer, ForeignKey("Users.ID"))
|
||||||
|
|
||||||
supervisor: Mapped[Optional['User']] = relationship('User', remote_side='User.id', back_populates='subordinates')
|
supervisor: Mapped[Optional['User']] = relationship('User', remote_side='User.id', back_populates='subordinates')
|
||||||
|
|
|
@ -423,6 +423,7 @@ def settings():
|
||||||
|
|
||||||
# It's a negative ID = created on frontend. Resolve from fallback list
|
# It's a negative ID = created on frontend. Resolve from fallback list
|
||||||
index = abs(resolved_id + 1)
|
index = abs(resolved_id + 1)
|
||||||
|
entry = None # Ensure entry is always defined
|
||||||
try:
|
try:
|
||||||
entry = fallback_list[index]
|
entry = fallback_list[index]
|
||||||
key = entry["name"] if isinstance(entry, dict) else str(entry).strip()
|
key = entry["name"] if isinstance(entry, dict) else str(entry).strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue