[orm-devel] Updates in one UPDATE statement

Diedrich Vorberg diedrich@tux4web.de
Sun, 17 Nov 2002 21:25:46 +0100

Hi Mike,

>What do you think about providing some capability to provide dbclass with
>an ability to perform all attribute updates in one pass? I'm speaking of
>course for an object which already exists in the database.

>A dbclass object could have an explicit or automatic update mode -
>explicit the developer is responsible for calling a "save" method.

again I can see the point in that being usefull but I don't like the
idea of having a special method for it, because it would spoil the
impression of orm being transperent. What I tought of is this: we
could use the __del__ special method of every dbclass which gets
called just before the class is garbage collected. This way one UPDATE
query could be sent to the database. The problem is, that you'd have 
to keep this in mind all the time. It is so subtle a thing it is 
likely to cause a great deal of confusion.

Another way would be to keep a list of all dbobjects that have been 
modified and let the ds's commit() method take care of the updates. 
Again this would create a situation in which interaction between orm 
and hand-writen SQL code would become difficult in a subtle manner. 

Maybe we should introduce a method ds.performUpdates() which gets
called by ds.commit(). If you want to do INSERTs or UPDATEs by hand
that depend on orm's UPDATEs you need to call performUpdates() and
than call commit() again after you're done.


           _..._                            Diedrich Vorberg
         .'     '.
        /  _   _  \                         http://www.tux4web.de
        | (o)_(o) |                         info@tux4web.de
         \(     ) /            .---.
         //'._.'\ \           /     \       Internet Dienstleistungen
        //   .   \ \          \.@-@./       und 'Consulting'.
       ||   .     \ \         /`\_/`\
       |\   :     / |        //  _  \\      Linux Rules!
       \ `) '   (`  /_      | \     )|_
     _)``".____,.'"` (_    /`\_`>  <_/ \
     )     )'--'(     (    \__/'---'\__/
      '---`      `---`