diff --git a/infrastructure/postgres/property_table.py b/infrastructure/postgres/property_table.py index 0b91a2ad..6bd2d644 100644 --- a/infrastructure/postgres/property_table.py +++ b/infrastructure/postgres/property_table.py @@ -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 diff --git a/repositories/property/property_postgres_repository.py b/repositories/property/property_postgres_repository.py index e0b4f9ff..55a32ed3 100644 --- a/repositories/property/property_postgres_repository.py +++ b/repositories/property/property_postgres_repository.py @@ -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: