- marked as critical
- changed title to Consider special flags/logic/other in TypeDecorator to ease production of custom `__eq__()` logic
Consider special flags/logic/other in TypeDecorator to ease production of custom `__eq__()` logic
This is a 0.8.0 -> 0.8.1 regression. Basically, I have a custom type decorator like the following:
class BitIndicatorType(types.TypeDecorator):
"""
Converts '0' and '1' bits to True/False values and vica-versa
"""
impl = types.SmallInteger
def process_bind_param(self, value, dialect):
return 1 if value else 0
def process_result_value(self, value, dialect):
return True if value == 1 else False
def copy(self):
return BitIndicatorType()
This type in turn is used in ORM mapped objects and in queries - so for example if we have enabledInd = Column('enabled_ind', BitIndicatorType) and obj.enabledInd == True then I expect the SQL to be: {{{... where enabled_ind = 1...}}}
However, due to https://github.com/zzzeek/sqlalchemy/commit/5884c2e7e5b46cee29b90aa3f7161e7380e3e2a5 the explicit boolean check added in expression.py _const_expr, the true gets passed to the dialect directly before being passed through the type decorator.
The expected behaviour is that the type decorator be checked even when the value is a boolean value.
Comments (4)
-
repo owner -
repo owner working patch is attached.
-
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.8.xx (automated comment)
- Log in to comment
please use the workaround in
#2734, applied to True/False.