[CalendarServer-changes] [9602] CalendarServer/branches/users/glyph/q

source_changes at macosforge.org source_changes at macosforge.org
Sat Aug 11 01:54:43 PDT 2012


Revision: 9602
          http://trac.macosforge.org/projects/calendarserver/changeset/9602
Author:   glyph at apple.com
Date:     2012-08-11 01:54:43 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
an implementation that fails in vaguely the right way

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/q/

Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py	2012-08-11 08:54:42 UTC (rev 9601)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py	2012-08-11 08:54:43 UTC (rev 9602)
@@ -33,6 +33,8 @@
 )
 from twext.enterprise.util import mapOracleOutputType
 
+from twisted.internet.defer import inlineCallbacks, returnValue
+
 try:
     import cx_Oracle
     cx_Oracle
@@ -1486,6 +1488,35 @@
         self.Return = Return
 
 
+    @inlineCallbacks
+    def on(self, txn, *a, **kw):
+        """
+        Override to provide extra logic for L{Update}s that return values on
+        databases that don't provide return values as part of their C{UPDATE}
+        behavior.
+        """
+        doExtra = self.Return is not None and txn.dialect == SQLITE_DIALECT
+        upcall = lambda: super(_DMLStatement, self).on(txn, *a, **kw)
+
+        if doExtra:
+            table = self._returnAsList()[0].model.table
+            rowidcol = ColumnSyntax(Column(table, "rowid",
+                                           SQLType("integer", None)))
+            prequery = Select([rowidcol], From=TableSyntax(table))
+            preresult = prequery.on(txn, *a, **kw)
+            before = yield preresult
+            yield upcall()
+            result = yield (Select(self._returnAsList(),
+                            # TODO: error reporting when 'return' includes
+                            # columns foreign to the primary table.
+                            From=TableSyntax(table),
+                            Where=rowidcol == before[0][0]
+                            ).on(txn, *a, **kw))
+            returnValue(result)
+        else:
+            returnValue(upcall())
+
+
     def _toSQL(self, queryGenerator):
         """
         @return: a 'insert' statement with placeholders and arguments
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/49605218/attachment-0001.html>


More information about the calendarserver-changes mailing list