[CalendarServer-changes] [7109] CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 7 18:58:43 PST 2011


Revision: 7109
          http://trac.macosforge.org/projects/calendarserver/changeset/7109
Author:   glyph at apple.com
Date:     2011-03-07 18:58:43 -0800 (Mon, 07 Mar 2011)
Log Message:
-----------
'delete using' syntax for DAL

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py
    CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py

Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py	2011-03-08 02:58:31 UTC (rev 7108)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py	2011-03-08 02:58:43 UTC (rev 7109)
@@ -748,17 +748,23 @@
     'delete' statement.
     """
 
-    def __init__(self, From, Where, Return=None):
+    def __init__(self, From, Where, Return=None, Using=None):
         self.From = From
         self.Where = Where
         self.Return = Return
+        self.Using = Using
 
 
     def toSQL(self, placeholder="?", quote=lambda x: x):
         result = SQLFragment()
         allTables = self.From.tables()
+        if self.Using is not None:
+            allTables += self.Using.tables()
         result.text += quote('delete from ')
         result.append(self.From.subSQL(placeholder, quote, allTables))
+        if self.Using is not None:
+            result.text += ' using '
+            result.append(self.Using.subSQL(placeholder, quote, allTables))
         result.text += quote(' where ')
         result.append(self.Where.subSQL(placeholder, quote, allTables))
         if self.Return is not None:

Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py	2011-03-08 02:58:31 UTC (rev 7108)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py	2011-03-08 02:58:43 UTC (rev 7109)
@@ -258,6 +258,24 @@
         )
 
 
+    def test_deleteUsing(self):
+        """
+        L{Delete}'s C{Using} parameter works similarly to the C{From} parameter
+        to L{Select}.
+        """
+        f = self.schema.FOO
+        o = self.schema.OTHER
+        self.assertEquals(
+            Delete(From=f, Using=o,
+                   Where=(f.BAR == o.BAR).And(o.FOO_BAR == 7)).toSQL(),
+            SQLFragment(
+                "delete from FOO using OTHER where FOO.BAR = OTHER.BAR and "
+                "FOO_BAR = ?",
+                [7]
+            )
+        )
+
+
     def test_columnSelection(self):
         """
         If a column is specified by the argument to L{Select}, those will be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110307/f57b9e45/attachment.html>


More information about the calendarserver-changes mailing list