Model/infrastructure/postgres/property_table.py
Khalim Conn-Kowlessar d89983d44f refactor(property): PropertyRow.id non-Optional (PR #1139 review)
`property` is an FE-owned table the backend only ever reads — every row read
carries an id — so the autoincrement-PK `Optional[int]` idiom doesn't apply
here. Make it `int` and drop the now-redundant None guard in get_many.

(Contrast: solar_table keeps Optional id — the backend DOES insert those, so
id is genuinely None pre-flush.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 16:28:48 +00:00

25 lines
927 B
Python

from __future__ import annotations
from typing import ClassVar, Optional
from sqlmodel import Field, SQLModel
class PropertyRow(SQLModel, table=True):
"""Defensive view of the FE-owned ``property`` table.
The schema and migrations for ``property`` are owned by the front-end
Next.js repo; this declares only the identity columns the modelling backend
reads/writes, so FE-owned migrations to other columns don't ripple into us.
"""
__tablename__: ClassVar[str] = "property" # pyright: ignore[reportIncompatibleVariableOverride]
# Non-Optional: this is a read-only defensive view of the FE-owned ``property``
# table — the backend never inserts rows, so every row read carries an id.
id: int = Field(primary_key=True)
portfolio_id: int
postcode: str
address: str
uprn: Optional[int] = Field(default=None)
landlord_property_id: Optional[str] = Field(default=None)