Underground-Digital/Workflow-Engine
0
1from sqlalchemy import CHAR, TypeDecorator2from sqlalchemy.dialects.postgresql import UUID3 4 5class StringUUID(TypeDecorator):6 impl = CHAR7 cache_ok = True8 9 def process_bind_param(self, value, dialect):10 if value is None:11 return value12 elif dialect.name == "postgresql":13 return str(value)14 else:15 return value.hex16 17 def load_dialect_impl(self, dialect):18 if dialect.name == "postgresql":19 return dialect.type_descriptor(UUID())20 else:21 return dialect.type_descriptor(CHAR(36))22 23 def process_result_value(self, value, dialect):24 if value is None:25 return value26 return str(value)27 