From 9d2ac59ed2a977b547b5cc7adb06413e0710805a Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 22 Jul 2026 16:12:18 +0000 Subject: [PATCH] =?UTF-8?q?Store=20uprn=20as=20BIGINT=20so=20real=2012-dig?= =?UTF-8?q?it=20UPRNs=20persist=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EpcPropertyModel.uprn was `Optional[int]`, which SQLModel maps to INTEGER, so a real 11/12-digit UPRN (e.g. 10000452538) overflowed int32 and hard-failed the insert with NumericValueOutOfRange — a failure on EVERY real-cert save, masked because the round-trip fixtures use small fake UPRNs. The FE `property.uprn` is already bigint; pin the column to BigInteger so ours matches (backend-only, no migration). Verified: uprn 10000452538 saves + reloads. Co-Authored-By: Claude Opus 4.8 (1M context) --- infrastructure/postgres/epc_property_table.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/infrastructure/postgres/epc_property_table.py b/infrastructure/postgres/epc_property_table.py index 512621d6c..f77128799 100644 --- a/infrastructure/postgres/epc_property_table.py +++ b/infrastructure/postgres/epc_property_table.py @@ -1,7 +1,7 @@ from __future__ import annotations from typing import ClassVar, Optional, Union -from sqlalchemy import Column +from sqlalchemy import BigInteger, Column from sqlalchemy import Enum as SAEnum from sqlalchemy.dialects.postgresql import JSONB from sqlmodel import SQLModel, Field @@ -36,7 +36,12 @@ class EpcPropertyModel(SQLModel, table=True): source: str = Field(default="lodged") # Identity / admin - uprn: Optional[int] = Field(default=None) + # BIGINT: real 12-digit UPRNs overflow int32 (the FE `property.uprn` is + # already bigint). SQLModel maps `int` -> INTEGER by default, so pin the + # column type or every real-UPRN insert hard-fails NumericValueOutOfRange. + uprn: Optional[int] = Field( + default=None, sa_column=Column(BigInteger, nullable=True) + ) uprn_source: Optional[str] = Field(default=None) report_reference: Optional[str] = Field(default=None) report_type: Optional[str] = Field(default=None)