On Sun, 2008-11-02 at 08:25 -0800, Jamu Kakar wrote: > Hi Brad, > > Brad Allen wrote: > > Is that the only way to get around this? It would be nice if I could > > perform a database update without doing any select at all. Sometimes the > > id value of the primary key is already available, and I just want to do > > an update without selecting first. > > > > In those situations, it would be nice if we could just do something like: > > > > customer = Customer (id=123, first_name = u'Jack', last_name = u'Sparrow') > > > > However, we can't use store.add for this object if we want it to > > generate an update statement; Storm usually generates an insert > > statement for store.add unless the object was already in the store as a > > result of store.find or store.get. > > 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.
Ah woo! That could come in handy if I need to tune performance. Thanks! There's also a PostgreSQL idiom using savepoints here: http://www.postgresql.org/docs/8.1/static/sql-update.html but that's moving away from using Storm as an abstraction layer. -- Justin Warren <[EMAIL PROTECTED]> -- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
