On Sun, Nov 2, 2008 at 11:25 AM, Jamu Kakar <[EMAIL PROTECTED]> wrote:
> You can use ResultSet.set to run an update without invoking object > creation and caching behaviour: > > result = store.find(Customer, Customer.id=123) > result.set(last_name=u"Sparrow-Hawk") > > If Store.find returns many rows, ResultSet.set will run an UPDATE > that affects all of them. > > I could see how that could come in handy sometimes, but what about cases where you have the primary key available and you still want to create that Customer instance in such a way that it will generate an update statement when flushed? In my case, I have a local cache (a Python dict) mapping one kind of id to another. This turns out to be faster in some situations than having doing a lot of individual select statements. My logic for determining insert/update is tied to whether an id is found in that dict cache. If the key isn't found, I create a new instance of the Storm class (such as Customer), but if is not found, I'd like to create a similar object in 'update mode'...or at least, I'd like to. That would help prevent duplicate code populating the same columns for both inserts and updates. -- ZeOmega Open Minds' Open Solutions 3010 Gaylord Parkway, Ste. 210 Frisco TX, 75034 http://www.zeomega.com Brad Allen 214-618-9880 (ext. 8006)
-- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
