8 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Spatial data (PostGI...
FromSent OnAttachments
Allen23 Feb 2007 09:37 
Allen Bierbaum25 Feb 2007 09:02 
Michael Bayer25 Feb 2007 11:20 
Allen Bierbaum25 Feb 2007 13:43 
Allen Bierbaum25 Feb 2007 15:03 
Allen Bierbaum27 Feb 2007 05:46 
Michael Bayer27 Feb 2007 08:41 
Michael Bayer27 Feb 2007 09:12 
Subject:[sqlalchemy] Re: Spatial data (PostGIS/OGC) with SqlAlchemy
From:Allen Bierbaum (abie@gmail.com)
Date:02/25/2007 03:03:07 PM
List:com.googlegroups.sqlalchemy

[snip]

When I use this with my table and datamapper code, it looks like everything is working fine but the generated SQL insert statement fails with a exception:

sqlalchemy.exceptions.SQLError: (ProgrammingError) parse error - invalid geometry 'INSERT INTO gis_entity (id, name, pos) VALUES (%(mId)s, %(mName)s, %(mPos)s)' {'mName': 'New entity', 'mId': 1L, 'mPos': "GeomFromText('POINT(100 100)',-1)"}

I know from using sql directly in pgadmin3 that this line works correctly:

insert into gis_entity (id, name, pos) values (2, 'New entity', GeomFromText('POINT(100 100)', -1));

Does anyone see how this varies from the sql statement issued by SA?

By looking at the postgres log I figured out what was causing the error, but I still don't know how to fix it.

The problem is that SA considers "GeomFromText('POINT(100 100)', -1)" to be a string so it puts it in single quotes when creating the SQL command to execute. This causes problems because them postgres doesn't know it could be calling a method instead. I have tried returning an sqlalchemy.func object but this doesn't work either.

Any ideas?

-Allen