Try and use 'process_result_value' and 'process_bind_param' if possible
This commit is contained in:
@@ -216,6 +216,15 @@ class EncryptedType(TypeDecorator, ScalarCoercible):
|
|||||||
"""Encrypt a value on the way in."""
|
"""Encrypt a value on the way in."""
|
||||||
if value is not None:
|
if value is not None:
|
||||||
self._update_key()
|
self._update_key()
|
||||||
|
|
||||||
|
try:
|
||||||
|
value = self.underlying_type.process_bind_param(
|
||||||
|
value, dialect)
|
||||||
|
|
||||||
|
except AttributeError:
|
||||||
|
# Doesn't have 'process_bind_param'
|
||||||
|
pass
|
||||||
|
|
||||||
return self.engine.encrypt(value)
|
return self.engine.encrypt(value)
|
||||||
|
|
||||||
def process_result_value(self, value, dialect):
|
def process_result_value(self, value, dialect):
|
||||||
@@ -223,6 +232,13 @@ class EncryptedType(TypeDecorator, ScalarCoercible):
|
|||||||
if value is not None:
|
if value is not None:
|
||||||
self._update_key()
|
self._update_key()
|
||||||
decrypted_value = self.engine.decrypt(value)
|
decrypted_value = self.engine.decrypt(value)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return self.underlying_type.process_result_value(
|
||||||
|
decrypted_value, dialect)
|
||||||
|
|
||||||
|
except AttributeError:
|
||||||
|
# Doesn't have 'process_result_value'
|
||||||
return self.underlying_type.python_type(decrypted_value)
|
return self.underlying_type.python_type(decrypted_value)
|
||||||
|
|
||||||
def _coerce(self, value):
|
def _coerce(self, value):
|
||||||
|
Reference in New Issue
Block a user