On Jan 29, 2009, at 1:19 PM, Werner F. Bruhin wrote:

>
> Michael,
>
> I run the following script and initially had the either my application
> and/or the IB Expert database tool (for Firebird SQL v 2.1) open at  
> the
> same time.  Now the following tests are done without any other task
> accessing the database.
>
> script:
> engine = db.sa.create_engine(dburl, encoding='utf8', echo=False)
> Session = db.sao.sessionmaker()
> Session.configure(bind=engine)
> session = Session()
>
> keyA = 174
> keyB = 175
>
> itemB = session.query(db.Cbbottle).get(keyB)
> print 'before move from B to A'
> print 'itemB id: %s' % itemB.cbbottleid
>
> for purch in itemB.purchase:
>    print 'purchasid: %s' % purch.purchaseid
>    print 'fk_cbbottleid: %s' % purch.fk_cbbottleid
>
> session.flush()
>
> itemA = session.query(db.Cbbottle).get(keyA)
> itemB = session.query(db.Cbbottle).get(keyB)
>
> print 'start to move from B to A'
> print 'itemA id: %s' % itemA.cbbottleid
>
> for purch in itemB.purchase:
>    print 'purchasid: %s' % purch.purchaseid
>    print 'fk_cbbottleid: %s' % purch.fk_cbbottleid
>    purch.cbbottle = itemA
>
> session.commit()
>
> itemA = session.query(db.Cbbottle).get(keyA)
> print 'after move from B to A'
> print 'itemA id: %s' % itemA.cbbottleid
>
> for purch in itemA.purchase:
>    print 'purchasid: %s' % purch.purchaseid
>    print 'fk_cbbottleid: %s' % purch.fk_cbbottleid
>
> The following is the output, note that purchasid "80" is not being  
> moved.
> before move from B to A
> itemB id: 175
> purchasid: 79
> fk_cbbottleid: 175
> purchasid: 80
> fk_cbbottleid: 175
> purchasid: 81
> fk_cbbottleid: 175
>
> start to move from B to A
> itemA id: 174
> purchasid: 79
> fk_cbbottleid: 175
> purchasid: 81
> fk_cbbottleid: 175

right there, purchasid 80 is not even in the list of items anymore.   
This is basically iterate the list, 80 is there, then flush(), then 80  
is not there.  this is all before anything has been "moved".   so  
either the flush() does something, or just the move of item #79  
affects something with #80.  try it without the flush(), and  
alternatively try iterating through the list a second time without  
moving the items, see if 80 disappears.   try without the delete- 
orphan too, perhaps thats triggering an event that is problematic.


--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to