Skip to content

Instantly share code, notes, and snippets.

@gigidn
Created February 10, 2021 18:16
Show Gist options
  • Save gigidn/871fd0a0d8009aa38cd46438f956e36c to your computer and use it in GitHub Desktop.
Save gigidn/871fd0a0d8009aa38cd46438f956e36c to your computer and use it in GitHub Desktop.
class UUID(Field):
""" Encapsulates an :class:`UUID`. """
type = 'uuid.UUID'
column_type = ('uuid', 'uuid')
def convert_to_column(self, value, record, values=None, validate=True):
return str(value)
def convert_to_cache(self, value, record, validate=True):
return str(value)
def convert_to_record(self, value, record):
if not value:
return None
return uuid.UUID(value)
def convert_to_read(self, value, record, use_name_get=True):
return str(value)
def convert_to_export(self, value, record):
if value:
return str(value)
return ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment