DetachedInstanceError when accessing relationship after session close in SQLAlchemy
Goal Determine the safest lazy‑loading configuration for ORM relationships that are serialized to JSON in a stateless web API while keeping response size predictable and avoiding DetachedInstanceError. Constraints The API creates a short‑lived Session per request and closes it before serialization. Relationships may be accessed multiple times during serializ