Eric Lemoine wrote: > > Hi > > Here's my case: I have > > - my own TypeEngine class, MyTypeEngine > - a Table with a Column using MyTypeEngine: > table = Table("tablename", metadata, > Column("columname", MyTypeEngine()), > autoload=True, autoload_with=engine > ) > - a class: > class MyClass(object): > pass > - and a mapping: > mapper(MyClass, table) > > Pretty standard. Now, instead of queries like this: > > SELECT columnname, ... FROM tablename > > I'd like queries like this: > > SELECT somefunc(columnname),... FROM tablename > > I thought I could get that by overriding my column's ColumnProperty > with something like that: > > mapper(MyClass, table, properties={ > "columname": column_property( > sql.func.somefunc(table.c.columname).label("columnname") > ) > }) > > but it doesn't work as I'd like because it seems that my TypeEngine is > no longer involved after querying my table - the function returned by > my TypeEngine's "result_process" method doesn't seem to be called. > > Is this expected? Do I have solutions to that problem?
somefunc() needs to specify the return type using type_=MyType, unless its a known "generic" function that knows to pass through the type of the first argument as that of the result (such as lower(), for example). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---