that sess.fulsh() in the middle there... if u move it up/down/out, 
will behaviour change? e.g. if u print the things in itemB.purchase 
just _After that flush - is 80 there or not?

On Thursday 29 January 2009 20:19:59 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
>
> after move from B to A
> itemA id: 174
> purchasid: 79
> fk_cbbottleid: 174
> purchasid: 81
> fk_cbbottleid: 174
>
> Without doing other tasks on the database I run the same script
> again, and get this output ("80" is now moved).
> before move from B to A
> itemB id: 175
> purchasid: 80
> fk_cbbottleid: 175
>
> start to move from B to A
> itemA id: 174
> purchasid: 80
> fk_cbbottleid: 175
>
> after move from B to A
> itemA id: 174
> purchasid: 79
> fk_cbbottleid: 174
> purchasid: 80
> fk_cbbottleid: 174
> purchasid: 81
> fk_cbbottleid: 174
>
> If I run the script again nothing is moved (which is obviously
> correct) and all shows under fk_cbbottleid "174", now I change the
> keyA and keyB variable and reverse the values as follows:
> keyA = 175
> keyB = 174
>
> Now I get this and again "80" is not moved.
> before move from B to A
> itemB id: 174
> purchasid: 79
> fk_cbbottleid: 174
> purchasid: 80
> fk_cbbottleid: 174
> purchasid: 81
> fk_cbbottleid: 174
>
> start to move from B to A
> itemA id: 175
> purchasid: 79
> fk_cbbottleid: 174
> purchasid: 81
> fk_cbbottleid: 174
>
> after move from B to A
> itemA id: 175
> purchasid: 79
> fk_cbbottleid: 175
> purchasid: 81
> fk_cbbottleid: 175
>
> I can repeat this again and again and it is always "80" which does
> not move the first time.
>
> Any ideas on what I can do to find out what is causing this row not
> to move would be very much appreciated.
>
> Werner
>
> 


--~--~---------~--~----~------------~-------~--~----~
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