Expectation: Once we perform the commit, the object properties are available. I've confirmed this by printing/logging the id of the person using person.id, and it outputs the correct value. to_dict() outputs null instead of the correct value. It doesn't seem to have the committed object.
Interestingly enough if I uncomment the logger.info line, or if I add db.session.refresh(), the to_dict() outputs the correct result.
This is the result when I execute it with the line# logger.info(f"id: ",person.id) uncommented.
This is my model:
This is the route:
Issue: If I execute this code, the logger and the create response will output a null id:
Expectation: Once we perform the commit, the object properties are available. I've confirmed this by printing/logging the id of the person using
person.id
, and it outputs the correct value.to_dict()
outputs null instead of the correct value. It doesn't seem to have the committed object.Interestingly enough if I uncomment the
logger.info
line, or if I add db.session.refresh(), theto_dict()
outputs the correct result.This is the result when I execute it with the line
# logger.info(f"id: ",person.id)
uncommented.