Hi

I'm facing another column_expression issue. It is not related to the
previous issue, and I'm sure if SQLAlchemy can help me with this one.

----
from sqlalchemy.types import UserDefinedType
from sqlalchemy.sql import func


class Geometry(UserDefinedType):

    def column_expression(self, col):
        return func.ST_AsBinary(col, type_=self)


from sqlalchemy import Table, Column, MetaData

lakes = Table('lake', MetaData(),
    Column('geom', Geometry)
    )

from sqlalchemy.sql.expression import select, alias
s = select([lakes])
a = alias(s, 'name')
s = a.select()
print s
----


The print statement returns this:


SELECT ST_AsBinary(name.geom) AS geom FROM (SELECT
ST_AsBinary(lake.geom) AS geom FROM lake) AS name


Which is expected. But the execution of this statement fails in my
PostGIS database, because ST_AsBinary cannot receive a bytea value as
input. (the outer ST_AsBinary call receives what's returned from the
inner ST_AsBinary call). It would work if ST_AsBinary was idempotent,
but it's not in PostGIS 2
(<http://trac.osgeo.org/postgis/ticket/1869>).

I'm stuck on this one.


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