I just wanted to followup to this thread to report success using the
patch provided below.
> You might want to try experimenting with a simple monkeypatch approach
> just to see what kind of results you get - this is just a guess based
> on a particular compiler hook we have that specifically processes
> columns being rendered within a select:
>
> from sqlalchemy.databases.postgres import PGCompiler
>
> def label_select_column(self, select, column, asfrom):
> if isinstance(col.type, MyGISType):
> return func.some_kml_function(col).label(column.name)
> else:
> return super(self, PGCompiler).label_select_column(select,
> column,
> asfrom)
>
> PGCompiler.label_select_column = label_select_column
>
> if the above leads to decent results we can attempt to add a hook onto
> TypeEngine perhaps.
Here's the exact patch that I ended up applying (only trivial
modifications from suggestion provided above).
from sqlalchemy.databases.postgres import PGCompiler
from sqlalchemy import func
def label_select_column(self, select, column, asfrom):
if isinstance(column.type, GeometryType):
return func.ST_AsEWKT(column).label(column.name)
else:
return super(PGCompiler, self).label_select_column(select,
column, asfrom)
PGCompiler.label_select_column = label_select_column
I assume that I should probably be doing something to handle the
"asfrom" parameter; however, this hasn't been a concern for me yet in
my codebase so I've put off investigating how the original
label_select_column does that.
Thanks again for the help.
Hans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---