import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Foo(Base):
__tablename__ = 'foo'
id = sa.Column(sa.Integer, primary_key=True)
bars = sa.orm.relationship("Bar", lazy="joined")
class Bar(Base):
__tablename__ = 'bar'
id = sa.Column(sa.Integer, primary_key=True)
foo_id = sa.Column(sa.Integer, sa.ForeignKey('foo.id'))
baz = sa.Column(sa.Integer)
e = sa.create_engine("sqlite://", echo=True)
session = sa.orm.Session(e)
session.query(Foo).options(sa.orm.load_only('id')).all()SELECT foo.id AS foo_id, bar_1.id AS bar_1_id, bar_1.foo_id AS bar_1_foo_id, bar_1.baz AS bar_1_baz
FROM foo LEFT OUTER JOIN bar AS bar_1 ON foo.id = bar_1.foo_idquery = session.query(model)
if properties is not None:
props = [p for p in properties if p in model.__table__.c]
query = query.options(sa.orm.load_only(*props))
noload = set([x.key for x in model.__mapper__.relationships]) - set(props)
for x in noload:
query = query.options(sa.orm.lazyload(x))
...>> <mailto:sqlalchemy+unsub...@googlegroups.com>.
Thanks for caring ;)
Thanks for posting a full self-contained working example of your problem!
--
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/DTqEnAKqipY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.