[CalendarServer-changes] [8784] CalendarServer/branches/users/glyph/case-insensitive-uid

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 29 10:15:34 PST 2012


Revision: 8784
          http://trac.macosforge.org/projects/calendarserver/changeset/8784
Author:   glyph at apple.com
Date:     2012-02-29 10:15:34 -0800 (Wed, 29 Feb 2012)
Log Message:
-----------
actually take the check constraint name into account when parsing

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/model.py
    CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/parseschema.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/case-insensitive-uid/

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/model.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/model.py	2012-02-29 18:15:29 UTC (rev 8783)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/model.py	2012-02-29 18:15:34 UTC (rev 8784)
@@ -86,12 +86,12 @@
     NOT_NULL = 'NOT NULL'
     UNIQUE = 'UNIQUE'
 
-    def __init__(self, type, affectsColumns):
+    def __init__(self, type, affectsColumns, name=None):
         self.affectsColumns = affectsColumns
         # XXX: possibly different constraint types should have different
         # classes?
         self.type = type
-        self.name = None
+        self.name = name
 
 
 
@@ -104,10 +104,10 @@
     """
     # XXX TODO: model for expression, rather than 
 
-    def __init__(self, syntaxExpression):
+    def __init__(self, syntaxExpression, name=None):
         self.expression = syntaxExpression
         super(Check, self).__init__(
-            'CHECK', [c.model for c in self.expression.allColumns()]
+            'CHECK', [c.model for c in self.expression.allColumns()], name
         )
 
 
@@ -308,14 +308,14 @@
         self.constraints.append(Constraint(constraintType, affectsColumns))
 
 
-    def checkConstraint(self, protoExpression):
+    def checkConstraint(self, protoExpression, name=None):
         """
         This table is affected by a 'check' constraint.  (Should only be called
         during schema parsing.)
 
         @param protoExpression: proto expression.
         """
-        self.constraints.append(Check(protoExpression))
+        self.constraints.append(Check(protoExpression, name))
 
 
     def insertSchemaRow(self, values):

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/parseschema.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/parseschema.py	2012-02-29 18:15:29 UTC (rev 8783)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/parseschema.py	2012-02-29 18:15:34 UTC (rev 8784)
@@ -304,9 +304,11 @@
         Parse a 'free' constraint, described explicitly in the table as opposed
         to being implicitly associated with a column by being placed after it.
         """
-        # only know about PRIMARY KEY and UNIQUE for now
+        ident = None
+        # TODO: make use of identifier in tableConstraint, currently only used
+        # for checkConstraint.
         if constraintType.match(Keyword, 'CONSTRAINT'):
-            expect(self, cls=Identifier) # constraintName
+            ident = expect(self, cls=Identifier).get_name()
             constraintType = expect(self, ttype=Keyword)
         if constraintType.match(Keyword, 'PRIMARY'):
             expect(self, ttype=Keyword, value='KEY')
@@ -316,7 +318,7 @@
             names = self.namesInParens(expect(self, cls=Parenthesis))
             self.table.tableConstraint(Constraint.UNIQUE, names)
         elif constraintType.match(Keyword, 'CHECK'):
-            self.table.checkConstraint(self.readExpression(self.next()))
+            self.table.checkConstraint(self.readExpression(self.next()), ident)
         else:
             raise ViolatedExpectation('PRIMARY or UNIQUE', constraintType)
         return self.checkEnd(self.next())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120229/74f1be60/attachment-0001.html>


More information about the calendarserver-changes mailing list