summaryrefslogtreecommitdiff
path: root/archivist/peewee_ext.py
diff options
context:
space:
mode:
Diffstat (limited to 'archivist/peewee_ext.py')
-rw-r--r--archivist/peewee_ext.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/archivist/peewee_ext.py b/archivist/peewee_ext.py
index 40fe5e7..ff03861 100644
--- a/archivist/peewee_ext.py
+++ b/archivist/peewee_ext.py
@@ -1,4 +1,4 @@
-from peewee import Field
+from peewee import Field, SQL
from itertools import starmap
from functools import reduce
@@ -42,3 +42,18 @@ class EnumField(Field):
def python_value(self, value):
return value if value is None else self._enum_value(value)
+class SQLIndex(SQL):
+ """Ugly hack to allow arbitrary index creation."""
+ def __init__(self, field, sql):
+ self.field = field
+ super().__init__(sql)
+
+ def clone_base(self):
+ return SQLWithField(field, self.value)
+
+ @property
+ def db_column(self):
+ return self.field
+
+ def as_entity(self):
+ return self