merge with 3.19.13
authorRémi Cardona <remi.cardona@logilab.fr>
Thu, 08 Oct 2015 18:38:16 +0200
changeset 10640 17bdc485c5b2
parent 10639 1ed205146ee2 (current diff)
parent 10630 d82b531fecd9 (diff)
child 10641 8f82e9523962
merge with 3.19.13
.hgtags
__pkginfo__.py
cubicweb.spec
debian/changelog
hooks/syncschema.py
server/migractions.py
server/sources/native.py
server/test/data/schema.py
server/test/unittest_migractions.py
--- a/.hgtags	Thu Oct 08 18:24:09 2015 +0200
+++ b/.hgtags	Thu Oct 08 18:38:16 2015 +0200
@@ -469,6 +469,9 @@
 5932de3d50bf023544c8f54b47898e4db35eac7c 3.19.12
 5932de3d50bf023544c8f54b47898e4db35eac7c debian/3.19.12-1
 5932de3d50bf023544c8f54b47898e4db35eac7c centos/3.19.12-1
+f933a38d7ab5fc6f2ad593fe1cf9985ce9d7e873 3.19.13
+f933a38d7ab5fc6f2ad593fe1cf9985ce9d7e873 debian/3.19.13-1
+f933a38d7ab5fc6f2ad593fe1cf9985ce9d7e873 centos/3.19.13-1
 7e6b7739afe6128589ad51b0318decb767cbae36 3.20.0
 7e6b7739afe6128589ad51b0318decb767cbae36 debian/3.20.0-1
 7e6b7739afe6128589ad51b0318decb767cbae36 centos/3.20.0-1
--- a/debian/changelog	Thu Oct 08 18:24:09 2015 +0200
+++ b/debian/changelog	Thu Oct 08 18:38:16 2015 +0200
@@ -64,6 +64,12 @@
 
  -- Julien Cristau <julien.cristau@logilab.fr>  Tue, 06 Jan 2015 18:11:03 +0100
 
+cubicweb (3.19.13-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- RĂ©mi Cardona <remi.cardona@logilab.fr>  Tue, 06 Oct 2015 18:31:33 +0200
+
 cubicweb (3.19.12-1) unstable; urgency=low
 
   * New upstream release
--- a/hooks/syncschema.py	Thu Oct 08 18:24:09 2015 +0200
+++ b/hooks/syncschema.py	Thu Oct 08 18:38:16 2015 +0200
@@ -696,6 +696,16 @@
         syssource = cnx.repo.system_source
         cstrtype = self.oldcstr.type()
         if cstrtype == 'SizeConstraint':
+            # if the size constraint is being replaced with a new max size, we'll
+            # call update_rdef_column in CWConstraintAddOp, skip it here
+            for cstr in cnx.transaction_data.get('newsizecstr', ()):
+                rdefentity = cstr.reverse_constrained_by[0]
+                cstrrdef = cnx.vreg.schema.schema_by_eid(rdefentity.eid)
+                if cstrrdef == rdef:
+                    return
+
+            # we found that the size constraint for this rdef is really gone,
+            # not just replaced by another
             syssource.update_rdef_column(cnx, rdef)
             self.size_cstr_changed = True
         elif cstrtype == 'UniqueConstraint':
@@ -775,6 +785,13 @@
     entity = cstrname = None # for pylint
     cols = () # for pylint
 
+    def insert_index(self):
+        # We need to run before CWConstraintDelOp: if a size constraint is
+        # removed and the column is part of a unique_together constraint, we
+        # remove the unique_together index before changing the column's type.
+        # SQL Server does not support unique indices on unlimited text columns.
+        return 0
+
     def precommit_event(self):
         cnx = self.cnx
         prefix = SQL_PREFIX
@@ -1205,6 +1222,11 @@
     events = ('after_add_entity', 'after_update_entity')
 
     def __call__(self):
+        if self.entity.cstrtype[0].name == 'SizeConstraint':
+            txdata = self._cw.transaction_data
+            if 'newsizecstr' not in txdata:
+                txdata['newsizecstr'] = set()
+            txdata['newsizecstr'].add(self.entity)
         CWConstraintAddOp(self._cw, entity=self.entity)
 
 
--- a/server/migractions.py	Thu Oct 08 18:24:09 2015 +0200
+++ b/server/migractions.py	Thu Oct 08 18:38:16 2015 +0200
@@ -458,7 +458,8 @@
         rtype = str(rtype)
         if rtype in self._synchronized:
             return
-        self._synchronized.add(rtype)
+        if syncrdefs and syncperms and syncprops:
+            self._synchronized.add(rtype)
         rschema = self.fs_schema.rschema(rtype)
         reporschema = self.repo.schema.rschema(rtype)
         if syncprops:
@@ -489,7 +490,8 @@
         etype = str(etype)
         if etype in self._synchronized:
             return
-        self._synchronized.add(etype)
+        if syncrdefs and syncperms and syncprops:
+            self._synchronized.add(etype)
         repoeschema = self.repo.schema.eschema(etype)
         try:
             eschema = self.fs_schema.eschema(etype)
@@ -587,9 +589,10 @@
         reporschema = self.repo.schema.rschema(rschema)
         if (subjtype, rschema, objtype) in self._synchronized:
             return
-        self._synchronized.add((subjtype, rschema, objtype))
-        if rschema.symmetric:
-            self._synchronized.add((objtype, rschema, subjtype))
+        if syncperms and syncprops:
+            self._synchronized.add((subjtype, rschema, objtype))
+            if rschema.symmetric:
+                self._synchronized.add((objtype, rschema, subjtype))
         rdef = rschema.rdef(subjtype, objtype)
         if rdef.infered:
             return # don't try to synchronize infered relation defs
--- a/server/sources/native.py	Thu Oct 08 18:24:09 2015 +0200
+++ b/server/sources/native.py	Thu Oct 08 18:38:16 2015 +0200
@@ -1703,7 +1703,7 @@
             self.logger.info('restoring sequence %s', seq)
             self.read_sequence(archive, seq)
         for numrange in numranges:
-            self.logger.info('restoring numrange %s', seq)
+            self.logger.info('restoring numrange %s', numrange)
             self.read_numrange(archive, numrange)
         for table in tables:
             self.logger.info('restoring table %s', table)
--- a/server/test/data/migratedapp/schema.py	Thu Oct 08 18:24:09 2015 +0200
+++ b/server/test/data/migratedapp/schema.py	Thu Oct 08 18:38:16 2015 +0200
@@ -108,6 +108,12 @@
 
 
 class Personne(EntityType):
+    __permissions__ = {
+        'read':   ('managers', 'users'), # 'guests' was removed
+        'add':    ('managers', 'users'),
+        'update': ('managers', 'owners'),
+        'delete': ('managers', 'owners')
+    }
     __unique_together__ = [('nom', 'prenom', 'datenaiss')]
     nom    = String(fulltextindexed=True, required=True, maxsize=64)
     prenom = String(fulltextindexed=True, maxsize=64)
--- a/server/test/data/schema.py	Thu Oct 08 18:24:09 2015 +0200
+++ b/server/test/data/schema.py	Thu Oct 08 18:38:16 2015 +0200
@@ -128,6 +128,12 @@
 
 
 class Personne(EntityType):
+    __permissions__ = {
+        'read':   ('managers', 'users', 'guests'), # 'guests' will be removed
+        'add':    ('managers', 'users'),
+        'update': ('managers', 'owners'),
+        'delete': ('managers', 'owners')
+    }
     __unique_together__ = [('nom', 'prenom', 'inline2')]
     nom    = String(fulltextindexed=True, required=True, maxsize=64)
     prenom = String(fulltextindexed=True, maxsize=64)
--- a/server/test/unittest_migractions.py	Thu Oct 08 18:24:09 2015 +0200
+++ b/server/test/unittest_migractions.py	Thu Oct 08 18:38:16 2015 +0200
@@ -435,6 +435,9 @@
             delete_concerne_rqlexpr = self._rrqlexpr_rset(cnx, 'delete', 'concerne')
             add_concerne_rqlexpr = self._rrqlexpr_rset(cnx, 'add', 'concerne')
 
+            # make sure properties (e.g. etype descriptions) are synced by the
+            # second call to sync_schema
+            mh.cmd_sync_schema_props_perms(syncprops=False, commit=False)
             mh.cmd_sync_schema_props_perms(commit=False)
 
             self.assertEqual(cnx.execute('Any D WHERE X name "Personne", X description D')[0][0],