Store uprn as BIGINT so real 12-digit UPRNs persist 🟩

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) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-22 16:12:18 +00:00
parent 6d2982f826
commit 9d2ac59ed2

View file

@ -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)