I've been looking through the sqlobject source for something like the
python iadd function that would allow incrementing fields using
``UPDATE table set field = field + delta'' to increment the field in an
atomic manner.
class StockFile(SQLObject):
qty_onhand IntegerCol()
qty_committed IntegerCol()
#...
class InvoiceLine(SQLObject):
stockno ForeignKey('Stockfle')
qty_ordered IntegerCol()
qty_shipped IntegerCol()
def _set_qty_ordered(self, value):
delta = value - self.qty_ordered
if delta != 0:
stockrec = Stockfle.get(stockno)
stockrec.qty_commited += delta
....
self._SO_set_custid(value.upper())
In the example above, the ``stockrec.qty_commited += delta'' would generate
the increment update to avoid any possibility of timing issues with
multiple processes updating simultaneously.
Somewhat related question -- if lazyupdates are true, and caching is false,
would updates like the above generate a single UPDATE command?
FWIW: We're primarily using postgresql-7.4.5 and postgresql-8.0.1 with
sqlobject.
Bill
--
INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
DOS: n., A small annoying boot virus that causes random spontaneous system
crashes, usually just before saving a massive project. Easily cured by
UNIX. See also MS-DOS, IBM-DOS, DR-DOS.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss