[schema2sql] Rename as_sql to constraint_value_as_sql
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 13 Jul 2016 12:18:32 +0200
changeset 11410 5e449033adcc
parent 11409 218815f40576
child 11411 9a5a6ec5fc09
[schema2sql] Rename as_sql to constraint_value_as_sql which is easier to grasp independantly of the context.
cubicweb/server/schema2sql.py
--- a/cubicweb/server/schema2sql.py	Wed Jul 13 12:17:37 2016 +0200
+++ b/cubicweb/server/schema2sql.py	Wed Jul 13 12:18:32 2016 +0200
@@ -186,7 +186,7 @@
     return '\n'.join(output)
 
 
-def as_sql(value, dbhelper, prefix):
+def constraint_value_as_sql(value, dbhelper, prefix):
     """Return the SQL value from a Yams constraint's value, handling special cases where it's a
     `Attribute`, `TODAY` or `NOW` instance instead of a literal value.
     """
@@ -211,15 +211,15 @@
     cstrname = 'cstr' + md5((eschema.type + attr + constraint.type() +
                              (constraint.serialize() or '')).encode('ascii')).hexdigest()
     if constraint.type() == 'BoundaryConstraint':
-        value = as_sql(constraint.boundary, dbhelper, prefix)
+        value = constraint_value_as_sql(constraint.boundary, dbhelper, prefix)
         return cstrname, '%s%s %s %s' % (prefix, attr, constraint.operator, value)
     elif constraint.type() == 'IntervalBoundConstraint':
         condition = []
         if constraint.minvalue is not None:
-            value = as_sql(constraint.minvalue, dbhelper, prefix)
+            value = constraint_value_as_sql(constraint.minvalue, dbhelper, prefix)
             condition.append('%s%s >= %s' % (prefix, attr, value))
         if constraint.maxvalue is not None:
-            value = as_sql(constraint.maxvalue, dbhelper, prefix)
+            value = constraint_value_as_sql(constraint.maxvalue, dbhelper, prefix)
             condition.append('%s%s <= %s' % (prefix, attr, value))
         return cstrname, ' AND '.join(condition)
     elif constraint.type() == 'StaticVocabularyConstraint':