[sqlalchemy] Re: Correct way of moving relation

2009-01-30 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: oh, duh. do it like this: for purchase in list(aItem.purchase): purchase.cbbottle = bItem I leave it to you as an exercise why this is the case. aItem.purchase is an instrumented list and as such is mutable, is that the right conclusion? Thanks

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Werner F. Bruhin wrote: I have some items which are related but I need to change it so they related to another item. Before getting myself in a mess (as I need to do this for a bunch of tables) I wanted to check if the following approach is fine. I am using SA 0.5, ORM and declarative

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Michael Bayer
On Jan 29, 2009, at 11:32 AM, Werner F. Bruhin wrote: Werner F. Bruhin wrote: I have some items which are related but I need to change it so they related to another item. Before getting myself in a mess (as I need to do this for a bunch of tables) I wanted to check if the following

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: ... there's no need to reassign the FK column yourself and the original pattern you're using is correct. that only one item in the list is the exception suggests something else is changing its state again further down the road. Thanks for the quick

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
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,

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread az
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

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Michael Bayer
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

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Michael Bayer wrote: .. 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

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Michael Bayer
oh, duh. do it like this: for purchase in list(aItem.purchase): purchase.cbbottle = bItem I leave it to you as an exercise why this is the case. On Jan 29, 2009, at 3:08 PM, Werner F. Bruhin wrote: Michael Bayer wrote: .. right there, purchasid 80 is not even in the list of