I'm having trouble with undefer_group(), which I'm sure used to work for me 
but now doesn't!

I've read the documentation regarding the changes to undefer_group() in 
0.9; I'm now using 1.0.14

I have a model, StockItem, with three column properties ('used', 'sold', 
'remaining') that are all deferred and in group 'qtys'.  Let's say I do a 
query like this (Delivery.items is a backref to StockItem):

        d = session.query(Delivery).\
            filter_by(id=int(deliveryid)).\
            options(joinedload_all('items.stocktype.unit'),
                    joinedload_all('items.stockline'),
                    defaultload("items").undefer_group('qtys')).\
            one()

I would expect StockItem.used, StockItem.sold and StockItem.remaining to be 
undeferred, but they are not.  If I do this:

        d = session.query(Delivery).\
            filter_by(id=int(deliveryid)).\
            options(joinedload_all('items.stocktype.unit'),
                    joinedload_all('items.stockline'),
                    defaultload("items")\
                    .undefer('used')\
                    .undefer('sold')\
                    .undefer('remaining')).\
            one()

...then it works as expected.

The 'used', 'sold' and 'remaining' columns are added to the StockItem class 
after it's defined, as follows:

StockItem.used = column_property(
    select([func.coalesce(func.sum(StockOut.qty), text("0.0"))]).\
        correlate(StockItem.__table__).\
        where(StockOut.stockid == StockItem.id).\
        label('used'),
    deferred=True,
    group="qtys",
    doc="Amount of this item that has been used for any reason")

Any ideas?

Stephen Early

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to