mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
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:
parent
3cad599fd1
commit
62e762e962
2 changed files with 4 additions and 2 deletions
|
|
@ -15,7 +15,9 @@ class PropertyRow(SQLModel, table=True):
|
||||||
|
|
||||||
__tablename__: ClassVar[str] = "property" # pyright: ignore[reportIncompatibleVariableOverride]
|
__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
|
portfolio_id: int
|
||||||
postcode: str
|
postcode: str
|
||||||
address: str
|
address: str
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class PropertyPostgresRepository(PropertyRepository):
|
||||||
rows = self._session.exec(
|
rows = self._session.exec(
|
||||||
select(PropertyRow).where(col(PropertyRow.id).in_(property_ids))
|
select(PropertyRow).where(col(PropertyRow.id).in_(property_ids))
|
||||||
).all()
|
).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)
|
epcs = self._epc_repo.get_for_properties(property_ids)
|
||||||
items: list[Property] = []
|
items: list[Property] = []
|
||||||
for property_id in property_ids:
|
for property_id in property_ids:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue