it's not safe to assume cache key status for any arguments passed to TypeDecorator and I wonder why the arguments here are even necessary to be part of a cache key. propose a simple flag cache_ok for TypeDecorator w/ a warning and NO_CACHE when not set.
from sqlalchemy import Column, Integer, create_engine, TypeDecorator, Unicode
from sqlalchemy.orm import sessionmaker, as_declarative, declared_attr
class AltType(TypeDecorator):
impl = Unicode(255)
def __init__(self, choices):
self.choices = choices
super(AltType, self).__init__()
@as_declarative()
class Base(object):
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
pk = Column(Integer, primary_key=True)
class MyClass(Base):
d = Column(AltType(['a', 'list', 'here']))
if __name__ == '__main__':
e = create_engine('sqlite://', echo=True)
conn = e.connect()
Base.metadata.create_all(e)
s = sessionmaker(e)()
q = s.query(MyClass).filter(MyClass.d == 'search_str')
result = q.first() # <---- error here
print(result)
it's not safe to assume cache key status for any arguments passed to TypeDecorator and I wonder why the arguments here are even necessary to be part of a cache key. propose a simple flag cache_ok for TypeDecorator w/ a warning and NO_CACHE when not set.