# HG changeset patch # User Sylvain Thénault # Date 1468405112 -7200 # Node ID 5e449033adcc1b34b22806f8169fd1f29e85fa66 # Parent 218815f405768f22bdf7a6968702e1ed6f18219d [schema2sql] Rename as_sql to constraint_value_as_sql which is easier to grasp independantly of the context. diff -r 218815f40576 -r 5e449033adcc 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':