add length in imp

This commit is contained in:
collerek
2021-03-09 17:29:29 +01:00
parent 2c31ad735d
commit 8d96a3fb84

View File

@ -7,6 +7,7 @@ from enum import Enum
from typing import Any, Callable, TYPE_CHECKING, Type, Union from typing import Any, Callable, TYPE_CHECKING, Type, Union
import sqlalchemy.types as types import sqlalchemy.types as types
from sqlalchemy.engine.default import DefaultDialect
from ormar import ModelDefinitionError from ormar import ModelDefinitionError
@ -115,7 +116,7 @@ class EncryptedString(types.TypeDecorator): # pragma nocover
Used to store encrypted values in a database Used to store encrypted values in a database
""" """
impl = types.String impl = types.TypeEngine
def __init__(self, def __init__(self,
*args: Any, *args: Any,
@ -140,11 +141,10 @@ class EncryptedString(types.TypeDecorator): # pragma nocover
self.max_length = encrypt_max_length self.max_length = encrypt_max_length
def __repr__(self) -> str: def __repr__(self) -> str:
return f"String({self.max_length})" return f"VARCHAR({self.max_length})"
# def load_dialect_impl(self, dialect: DefaultDialect) -> Any:
# def load_dialect_impl(self, dialect: DefaultDialect) -> Any: return dialect.type_descriptor(types.VARCHAR(self.max_length))
# dialect.type_descriptor(VARCHAR(self.max_length))
@property @property
def key(self): def key(self):