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

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


Revision: 9591
          http://trac.macosforge.org/projects/calendarserver/changeset/9591
Author:   glyph at apple.com
Date:     2012-08-11 01:54:34 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
Fix the test, and move the code to affect just 'insert' rather than all DML (since other DML requires other workarounds)

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:33 UTC (rev 9590)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py	2012-08-11 08:54:34 UTC (rev 9591)
@@ -1264,12 +1264,11 @@
 
     def _returningClause(self, queryGenerator, stmt, allTables):
         """
-        Add a dialect-appropriate 'returning' clause to the end of the given SQL
-        statement.
+        Add a dialect-appropriate 'returning' clause to the end of the given
+        SQL statement.
 
-        @param queryGenerator: describes the database we are generating the statement
-            for.
-
+        @param queryGenerator: describes the database we are generating the
+            statement for.
         @type queryGenerator: L{QueryGenerator}
 
         @param stmt: the SQL fragment generated without the 'returning' clause
@@ -1336,26 +1335,7 @@
         return self._returnAsList()
 
 
-    def on(self, txn, *a, **kw):
-        """
-        Override to provide potentially extra logic for insert/update/delete
-        that return values on databases that don't necessarily provide it.
-        """
-        result = super(_DMLStatement, self).on(txn, *a, **kw)
-        if txn.dialect == SQLITE_DIALECT:
-            table = self._returnAsList()[0].model.table
-            return Select(self._returnAsList(),
-                   # TODO: error reporting when 'return' includes columns
-                   # foreign to the primary table.
-                   From=TableSyntax(table),
-                   Where=ColumnSyntax(Column(table, "rowid",
-                                             SQLType("integer", None))) ==
-                         _sqliteLastInsertRowID()
-                   ).on(txn, *a, **kw)
-        return result
 
-
-
 class _OracleOutParam(object):
     """
     A parameter that will be populated using the cx_Oracle API for host
@@ -1435,7 +1415,26 @@
         return self._returningClause(queryGenerator, stmt, allTables)
 
 
+    def on(self, txn, *a, **kw):
+        """
+        Override to provide potentially extra logic for insert/update/delete
+        that return values on databases that don't necessarily provide it.
+        """
+        result = super(_DMLStatement, self).on(txn, *a, **kw)
+        if self.Return is not None and txn.dialect == SQLITE_DIALECT:
+            table = self._returnAsList()[0].model.table
+            return Select(self._returnAsList(),
+                   # TODO: error reporting when 'return' includes columns
+                   # foreign to the primary table.
+                   From=TableSyntax(table),
+                   Where=ColumnSyntax(Column(table, "rowid",
+                                             SQLType("integer", None))) ==
+                         _sqliteLastInsertRowID()
+                   ).on(txn, *a, **kw)
+        return result
 
+
+
 def _convert(x):
     """
     Convert a value to an appropriate SQL AST node.  (Currently a simple
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/175f2b1e/attachment-0001.html>


More information about the calendarserver-changes mailing list