[migractions] dropped_constraints should accept only droprequired without cstrtype stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 20 May 2011 17:27:15 +0200
branchstable
changeset 7409 47c8009dbbe2
parent 7408 9ad9ce340c5f
child 7410 1dbf9a83bb49
[migractions] dropped_constraints should accept only droprequired without cstrtype
server/migractions.py
--- 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]