server/migractions.py
branchstable
changeset 7409 47c8009dbbe2
parent 7342 d1c8b5b3531c
child 7410 1dbf9a83bb49
--- a/server/migractions.py	Fri May 20 17:20:51 2011 +0200
+++ b/server/migractions.py	Fri May 20 17:27:15 2011 +0200
@@ -1424,7 +1424,7 @@
         return self.cmd_create_entity(etype, *args, **kwargs).eid
 
     @contextmanager
-    def cmd_dropped_constraints(self, etype, attrname, cstrtype,
+    def cmd_dropped_constraints(self, etype, attrname, cstrtype=None,
                                 droprequired=False):
         """context manager to drop constraints temporarily on fs_schema
 
@@ -1444,8 +1444,9 @@
         rdef = self.fs_schema.eschema(etype).rdef(attrname)
         original_constraints = rdef.constraints
         # remove constraints
-        rdef.constraints = [cstr for cstr in original_constraints
-                            if not (cstrtype and isinstance(cstr, cstrtype))]
+        if cstrtype:
+            rdef.constraints = [cstr for cstr in original_constraints
+                                if not (cstrtype and isinstance(cstr, cstrtype))]
         if droprequired:
             original_cardinality = rdef.cardinality
             rdef.cardinality = '?' + rdef.cardinality[1]