eventcally/project/dbtypes.py
Daniel Grams d63f340384 Internal/modules (#1)
* Restructured app
* Added Travis CI
* Added 'Deploy to heroku' button
2020-11-13 12:24:26 +01:00

17 lines
459 B
Python

from sqlalchemy.types import TypeDecorator
from sqlalchemy import Integer
class IntegerEnum(TypeDecorator):
impl = Integer
def __init__(self, enumtype, *args, **kwargs):
super().__init__(*args, **kwargs)
self._enumtype = enumtype
def process_bind_param(self, value, dialect):
return value
def process_result_value(self, value, dialect):
if value:
return self._enumtype(value)
return None