On Saturday, June 7, 2014 12:59:42 PM UTC-4, Michael Bayer wrote: > > > If this is more at the user land level, I’d do a type like this: > > class TinyintBoolean(TypeDecorator): > impl = TINYINT > > def process_bind_param(self, value, dialect): > return None if value is None else bool(value) > > def process_result_value(self, value, dialect): > return bool(value) if value is not None else None > > then I’d again intercept “after_parent_attach” on Boolean, and at that > point swap out the Boolean type object on the Column for TinyintBoolean. > This is how you should go for now. >
Thanks Mike, that works like a charm. > > The idea that compilation of a type should be passed the Column or SQL > expression that it is a part of is a good one, as we do typically always > have that available (note that this is not just within DDL - we render > types in CAST expressions as well, but there’s still a parent SQL > expression). But this would require a major change to the API of > TypeCompiler, all the visit_XYZ() methods would at least now need to accept > **kwargs. Some trickery would be needed to accommodate old dialects. > I’ve added > https://bitbucket.org/zzzeek/sqlalchemy/issue/3074/allow-kw-for-typecompiler-specifically > > which includes a patch but this would be for 1.0 at the earliest. I'll keep an eye on that issue. Thanks again, You and SQLAlchemy truly are one of the most impressive projects I use on a daily basis. Michael -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.