From f1d6ba4ecc0c59f48ad6853d19a7041c600b5811 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 30 Oct 2014 13:57:27 -0700 Subject: [PATCH] Handle 'sa.Boolean' for 'EncryptedType' --- sqlalchemy_utils/types/encrypted.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sqlalchemy_utils/types/encrypted.py b/sqlalchemy_utils/types/encrypted.py index e3f000a..4f5ec29 100644 --- a/sqlalchemy_utils/types/encrypted.py +++ b/sqlalchemy_utils/types/encrypted.py @@ -223,8 +223,12 @@ class EncryptedType(TypeDecorator, ScalarCoercible): except AttributeError: # Doesn't have 'process_bind_param' - pass + # Handle 'boolean' + if issubclass(self.underlying_type.python_type, bool): + value = "true" if value else "false" + + print("encrypt: ", value) return self.engine.encrypt(value) def process_result_value(self, value, dialect): @@ -239,6 +243,12 @@ class EncryptedType(TypeDecorator, ScalarCoercible): except AttributeError: # Doesn't have 'process_result_value' + + # Handle 'boolean' + if issubclass(self.underlying_type.python_type, bool): + return decrypted_value == "true" + + # Handle all others return self.underlying_type.python_type(decrypted_value) def _coerce(self, value):