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>
This commit is contained in:
Khalim Conn-Kowlessar 2026-06-01 14:58:11 +00:00
parent 3cad599fd1
commit 62e762e962
2 changed files with 4 additions and 2 deletions

View file

@ -15,7 +15,9 @@ class PropertyRow(SQLModel, table=True):
__tablename__: ClassVar[str] = "property" # pyright: ignore[reportIncompatibleVariableOverride]
id: Optional[int] = Field(default=None, primary_key=True)
# 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

View file

@ -42,7 +42,7 @@ class PropertyPostgresRepository(PropertyRepository):
rows = self._session.exec(
select(PropertyRow).where(col(PropertyRow.id).in_(property_ids))
).all()
row_by_id = {row.id: row for row in rows if row.id is not None}
row_by_id = {row.id: row for row in rows}
epcs = self._epc_repo.get_for_properties(property_ids)
items: list[Property] = []
for property_id in property_ids: