# they are expunged and set to transient state. Their attributes will not be
# changed.
#     For persistent instances result by query(), they are still persistent
# but expired, which means that qualify their attributes will reload them by
# emitting a query.
#     All objects not expunged are fully expired.
################################################################################
session.rollback() 

################################################################################
#                               expire
# expire erase instances' attributes, and when those attributes are next
# accessed, a query is emitted. Only persistent instances has expired state.
################################################################################

session.expire(user)
session.expire_all() 


################################################################################
#                             manage relationship
#     emit a query and load relationship objects during the first qualification
# if no eager load is applied.
################################################################################

# load ########################################################
# may emit a quer
addresses = user.addresses

# eager load through left join
session.query(User).options('addresses')
Exemple #2
0
def refresh_object(session: Session, obj: Model) -> None:
    session.expire(obj)
    session.refresh(obj)
Exemple #3
0
# they are expunged and set to transient state. Their attributes will not be
# changed.
#     For persistent instances result by query(), they are still persistent
# but expired, which means that qualify their attributes will reload them by
# emitting a query.
#     All objects not expunged are fully expired.
################################################################################
session.rollback()

################################################################################
#                               expire
# expire erase instances' attributes, and when those attributes are next
# accessed, a query is emitted. Only persistent instances has expired state.
################################################################################

session.expire(user)
session.expire_all()

################################################################################
#                             manage relationship
#     emit a query and load relationship objects during the first qualification
# if no eager load is applied.
################################################################################

# load ########################################################
# may emit a quer
addresses = user.addresses

# eager load through left join
session.query(User).options('addresses')