I thought this was working yesterday before svn update, but I can't be
sure.

I have two tables, related like this:

mapper(Shipment, TShipment,
       order_by=TShipment.c.id,
       properties={
           'quote_xml': deferred(TShipment.c.quote_xml),
           'quote_pickle': deferred(TShipment.c.quote_pickle),
           'raw_manifest': deferred(TShipment.c.raw_manifest),
           'decoded_manifest': deferred(TShipment.c.decoded_manifest),
           'packages': relation(Package, backref="shipment",
cascade="all, delete-orphan"),

           'voided_packages': relation(Package, primaryjoin=\
                                           and_(TShipment.c.id ==
TPackage.c.shipment_id,

TPackage.c.void_confirmed != None
                                           )
                                       ),
           'nonvoid_packages': relation(Package, primaryjoin=\
                                           and_(TShipment.c.id ==
TPackage.c.shipment_id,

TPackage.c.void_confirmed == None
                                           )
                                       )
    })

my code loads a shipment, then does a len(shipment.nonvoid_packages),
and gets the proper number.

Then it decides it needs to void a package, so it sets the package's
void_confirmed date and  session.flush()

later, the code does another len(shipment.nonvoid_packages) and the
already voided package is still counted as non-void.

Are custom joins supposed to be re-evaluated when there's a change to
one of the tables in the join?

The first non-void lookup:

select  stuff FROM package
WHERE ? = package.shipment_id AND package.void_confirmed IS NULL ORDER
BY package.id
2006-11-16 17:18:14,707 INFO
sqlalchemy.engine.threadlocal.TLEngine.0x..94 [138]

void_confirmed::

2006-11-16 17:18:15,071 INFO
sqlalchemy.engine.threadlocal.TLEngine.0x..94 UPDATE package SET
void_confirmed=? WHERE package.id = ?
INFO:sqlalchemy.engine.threadlocal.TLEngine.0x..94:UPDATE package SET
void_confirmed=? WHERE package.id = ?
2006-11-16 17:18:15,072 INFO
sqlalchemy.engine.threadlocal.TLEngine.0x..94 [datetime.datetime(2006,
11, 16, 17, 18, 15, 67070), 214]
INFO:sqlalchemy.engine.threadlocal.TLEngine.0x..94:[datetime.datetime(2006,
11, 16, 17, 18, 15, 67070), 214]

Later this code runs::

            if len(existing_shipment.nonvoid_packages) != 0:
                for package in existing_shipment.nonvoid_packages:
                    print "non-void package tr %r, void date %r" %
(package.trackingnumber, package.void_confirmed)

and the output:

non-void package tr '013514470107311', void date
datetime.datetime(2006, 11, 16, 17, 18, 15, 67070)


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to