On Tue, Sep 29, 2009 at 9:04 PM, Michael Bayer <mike...@zzzcomputing.com> wrote:
>
> 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).

it's a postgis function. How do I specify the return type using
type_=MyType? Sorry i didn't follow you on that one.

thanks


>
> >
>



-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to