Re: [sqlalchemy] Is it possible to use relationship(lazy='raise') after session.refresh?

2019-09-25 Thread Mike Bayer
OK, the first load is expected, because when you session.query(X).options(someload(X.y)), the query will load all the ".y" for objects that it finds already in the identity map, however it will not establish someload() as a new permanent option on that X going forward, so subsequent loads use

Re: [sqlalchemy] Is it possible to use relationship(lazy='raise') after session.refresh?

2019-09-25 Thread Mike Bayer
what you are seeing is somewhat backwards due to what might be a bug. in the example you have, *both* calls to group.users should be raising, because this object is already present in the identity map so your lazyload() option should not affect this already-present Group object. if you load

[sqlalchemy] Is it possible to use relationship(lazy='raise') after session.refresh?

2019-09-25 Thread Marat Sharafutdinov
from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import lazyload, relationship, sessionmaker Base = declarative_base() class Group(Base): __tablename__ = 'groups' id = Column(Integer,