[schema] add a unique index on cwuri
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 25 Feb 2015 10:33:41 +0100
changeset 10371 88577b10b31e
parent 10370 480187dd66b3
child 10374 699e49d76334
[schema] add a unique index on cwuri Closes #4985752
entity.py
misc/migration/3.21.0_Any.py
schemas/base.py
--- a/entity.py	Thu Feb 13 16:37:40 2014 +0100
+++ b/entity.py	Wed Feb 25 10:33:41 2015 +0100
@@ -425,7 +425,7 @@
         else:
             for rschema in cls.e_schema.subject_relations():
                 if (rschema.final
-                    and rschema != 'eid'
+                    and rschema not in ('eid', 'cwuri')
                     and cls.e_schema.has_unique_values(rschema)
                     and cls.e_schema.rdef(rschema.type).cardinality[0] == '1'):
                     mainattr = str(rschema)
--- a/misc/migration/3.21.0_Any.py	Thu Feb 13 16:37:40 2014 +0100
+++ b/misc/migration/3.21.0_Any.py	Wed Feb 25 10:33:41 2015 +0100
@@ -19,3 +19,5 @@
 commit()
 
 sync_schema_props_perms('CWEType')
+
+sync_schema_props_perms('cwuri')
--- a/schemas/base.py	Thu Feb 13 16:37:40 2014 +0100
+++ b/schemas/base.py	Wed Feb 25 10:33:41 2015 +0100
@@ -23,7 +23,7 @@
 from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
                             SubjectRelation,
                             String, TZDatetime, Datetime, Password, Interval,
-                            Boolean)
+                            Boolean, UniqueConstraint)
 from cubicweb.schema import (
     RQLConstraint, WorkflowableEntityType, ERQLExpression, RRQLExpression,
     PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, PUB_SYSTEM_ATTR_PERMS)
@@ -164,6 +164,7 @@
     cardinality = '11'
     subject = '*'
     object = 'String'
+    constraints = [UniqueConstraint()]
 
 
 # XXX find a better relation name
@@ -183,7 +184,6 @@
     cardinality = '?*'
 
 
-
 class ExternalUri(EntityType):
     """a URI representing an object in external data store"""
     uri = String(required=True, unique=True, maxsize=256,