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

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 7 19:03:32 PST 2011


Revision: 7133
          http://trac.macosforge.org/projects/calendarserver/changeset/7133
Author:   glyph at apple.com
Date:     2011-03-07 19:03:32 -0800 (Mon, 07 Mar 2011)
Log Message:
-----------
represent 'on delete cascade' also

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/model.py
    CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/parseschema.py
    CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_parseschema.py

Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/model.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/model.py	2011-03-08 03:03:17 UTC (rev 7132)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/model.py	2011-03-08 03:03:32 UTC (rev 7133)
@@ -140,6 +140,11 @@
     @ivar references: If this column references a foreign key on another table,
         this will be a reference to that table; otherwise (normally) C{None}.
     @type references: L{Table} or C{NoneType}
+
+    @ivar cascade: If this column references another table, will this column's
+        row be deleted when the matching row in that other table is deleted?
+        (In other words, the SQL feature 'on delete cascade'.)
+    @type cascade: C{bool}
     """
 
     def __init__(self, table, name, type):
@@ -149,6 +154,7 @@
         self.type = type
         self.default = NO_DEFAULT
         self.references = None
+        self.cascade = False
 
 
     def __repr__(self):

Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/parseschema.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/parseschema.py	2011-03-08 03:03:17 UTC (rev 7132)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/parseschema.py	2011-03-08 03:03:32 UTC (rev 7133)
@@ -353,6 +353,7 @@
                 elif val.match(Keyword, 'ON'):
                     expect(self, ttype=Keyword.DML, value='DELETE')
                     expect(self, ttype=Keyword, value='CASCADE')
+                    theColumn.cascade = True
                 else:
                     expected = False
                 if not expected:

Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_parseschema.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_parseschema.py	2011-03-08 03:03:17 UTC (rev 7132)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_parseschema.py	2011-03-08 03:03:32 UTC (rev 7133)
@@ -228,3 +228,19 @@
                           (a.columnNamed("b"), a.columnNamed("c")))
 
 
+    def test_cascade(self):
+        """
+        A column with an 'on delete cascade' constraint will have its C{cascade}
+        attribute set to True.
+        """
+        s = Schema()
+        addSQLToSchema(
+            s,
+            """
+            create table a (b integer primary key);
+            create table c (d integer references a on delete cascade);
+            """)
+        self.assertEquals(s.tableNamed("a").columnNamed("b").cascade, False)
+        self.assertEquals(s.tableNamed("c").columnNamed("d").cascade, True)
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110307/581f05f2/attachment-0001.html>


More information about the calendarserver-changes mailing list