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
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
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,