Here's a helper function that accommodates for the object being expired:
from sqlalchemy.orm import exc
from sqlalchemy import inspect
def safe_is_persistent(obj):
state = inspect(obj)
if state.expired:
try:
state.mapper.primary_key_from_instance(obj)
except
On Fri, Aug 24, 2018 at 3:12 AM, Chris Wilson
wrote:
> Dear Michael,
>
>
>
> I have discovered that under very particular circumstances, SQLAlchemy
> forgets that an object was newly created in a transaction, and if that
> transaction rolls back, the object’s state is not reset from persistent to
Dear Michael,
I have discovered that under very particular circumstances, SQLAlchemy forgets
that an object was newly created in a transaction, and if that transaction
rolls back, the object's state is not reset from persistent to transient.
It seems to rely on the following:
*Open