cubicweb/server/schema2sql.py
changeset 11416 9c2fbb872e91
parent 11413 c172fa18565e
child 11766 d8de1ac21f36
--- a/cubicweb/server/schema2sql.py	Fri Jul 08 10:17:14 2016 +0200
+++ b/cubicweb/server/schema2sql.py	Fri Jul 08 10:17:42 2016 +0200
@@ -168,11 +168,8 @@
     """Return (constraint name, constraint SQL definition) for the given relation definition's
     constraint. Maybe (None, None) if the constraint is not handled in the backend.
     """
-    eschema = rdef.subject
     attr = rdef.rtype.type
-    # XXX should find a better name
-    cstrname = 'cstr' + md5((eschema.type + attr + constraint.type() +
-                             (constraint.serialize() or '')).encode('ascii')).hexdigest()
+    cstrname = constraint.name_for(rdef)
     if constraint.type() == 'BoundaryConstraint':
         value = constraint_value_as_sql(constraint.boundary, dbhelper, prefix)
         return cstrname, '%s%s %s %s' % (prefix, attr, constraint.operator, value)