160 # XXX more quoting for literals? |
160 # XXX more quoting for literals? |
161 return value |
161 return value |
162 |
162 |
163 def check_constraint(eschema, aschema, attr, constraint, dbhelper, prefix=''): |
163 def check_constraint(eschema, aschema, attr, constraint, dbhelper, prefix=''): |
164 # XXX should find a better name |
164 # XXX should find a better name |
165 cstrname = 'cstr' + md5(eschema.type + attr + constraint.type() + |
165 cstrname = 'cstr' + md5((eschema.type + attr + constraint.type() + |
166 (constraint.serialize() or '')).hexdigest() |
166 (constraint.serialize() or '')).encode('ascii')).hexdigest() |
167 if constraint.type() == 'BoundaryConstraint': |
167 if constraint.type() == 'BoundaryConstraint': |
168 value = as_sql(constraint.boundary, dbhelper, prefix) |
168 value = as_sql(constraint.boundary, dbhelper, prefix) |
169 return cstrname, '%s%s %s %s' % (prefix, attr, constraint.operator, value) |
169 return cstrname, '%s%s %s %s' % (prefix, attr, constraint.operator, value) |
170 elif constraint.type() == 'IntervalBoundConstraint': |
170 elif constraint.type() == 'IntervalBoundConstraint': |
171 condition = [] |
171 condition = [] |