Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-04 Thread Kevin S
Yes, I would say that is an acceptable solution to me. My current attempt, which I think might work, is to grab all the primary keys off the original list of objects, then use those on an IN clause where I load only the primary key (by deferring everything else) of the parent and the desired

[sqlalchemy] Adjacency list + Abstract Base Class Inheritance used in relationship

2014-11-04 Thread delijati
Hello, i posted my question on stakoverflow. So to not repeat myself: https://stackoverflow.com/questions/26724897/adjacency-list-abstract-base-class-inheritance-used-in-relationship Josip -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-04 Thread Michael Bayer
I was thinking of sqlalchemy-utils: https://github.com/kvesteri/sqlalchemy-utils https://github.com/kvesteri/sqlalchemy-utils , as I recall Konsta showing me the loader he wrote, but now I’m not seeing it here. I’ll keep poking around. You might want to take a look at the example for

Re: [sqlalchemy] Adjacency list + Abstract Base Class Inheritance used in relationship

2014-11-04 Thread Michael Bayer
there is a lot lot lot going on here. The example isn’t working in 1.0 for different reasons, for example. However lets start with just the error you have, and to do that, lets please just show the minimal amount of code to reproduce: from sqlalchemy import * from sqlalchemy.orm import *

Re: [sqlalchemy] Adjacency list + Abstract Base Class Inheritance used in relationship

2014-11-04 Thread Michael Bayer
OK, coffee has been applied.This mapping can be done in 0.9 but only if you use classical mappings, AbstractConcreteBase and declarative aren’t ready yet. In 1.0, I made a lot of improvements (see

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-04 Thread Kevin S
Ah yes, perfect! The set_committed_value was the last piece I needed, to prevent lazy loading while setting the new values from the IN clause query. I like that DisjointEagerLoading recipe, as it pretty much captures the same idea. Oh, and perhaps I should say it again in case anyone in the

[sqlalchemy] objects not necessarily pulled from session's identity map when they should (?)

2014-11-04 Thread Jonathan Vanasco
I've been going batty on this all morning. I have a permissions check routine that repeatedly queries for a certain Foo2Bar table class Foo2Bar(Base): __tablename__ = 'foo_2_bar' id_foo = Column(Integer, ForeignKey(foo.id), primary_key=True) id_bar = Column(Integer,

Re: [sqlalchemy] objects not necessarily pulled from session's identity map when they should (?)

2014-11-04 Thread Claudio Freire
On Tue, Nov 4, 2014 at 3:15 PM, Jonathan Vanasco jvana...@gmail.com wrote: I have a permissions check routine that repeatedly queries for a certain Foo2Bar table class Foo2Bar(Base): __tablename__ = 'foo_2_bar' id_foo = Column(Integer, ForeignKey(foo.id),

Re: [sqlalchemy] objects not necessarily pulled from session's identity map when they should (?)

2014-11-04 Thread Jonathan Vanasco
Thanks! I didn't realize that objects are cleaned up with scope like normal python objects. I thought they were in the session for the lifetime of the session. This was driving me crazy. This is just a web request, so I'm now appending the result into `request.persistanceArray`. instantly

[sqlalchemy] simple join to parent with group_by

2014-11-04 Thread nathan
I’m trying to get a simple join working to a parent table with group_by. I’ve tried some variations working from the ORM tutorial but keep running into exceptions or I get multiple queries. I’m trying to get a single query that results in a collection of Client instances that’s joined to and

Re: [sqlalchemy] simple join to parent with group_by

2014-11-04 Thread Michael Bayer
query.options(joinedload()) is not used for creating joins, you need you use query.join(). See

[sqlalchemy] behavior of multiple correlated subqueries different from 0.7.10 to 0.9.8

2014-11-04 Thread Meelap Shah
I am trying to perform a query in which I from multiple correlated subqueries. My code works with 0.7.10, but not with 0.9.8. Base = declarative_base() class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) name = Column(String) class Action(Base):