On Sep 19, 2008, at 12:52 PM, Hans Lellelid wrote:

>
> Hi,
>
> I'm using SA 0.4.6 and I'm having trouble using the result of a
> database function / stored procedure in an UPDATE statement (being
> constructed with SQL expression lang).   This happens to be for using
> PostGIS columns; however, that is not relevant to the problem here.  I
> have tried doing some searching on this in the manual and in user
> group, but have not found an answer.
>
> A simplified version of my python code looks like this:
>
> mytable.update(mytable.c.id==idvar, {'geocolumn':
> func.GeomFromText(wkt, 4326)})
>
> The function is being quoted and some other weird stuff is happening,
> such that I have result SQL that looks like:
>
> UPDATE mytable SET geocolumn =
> E'GeomFromText(''GeomFromText(:GeomFromText_1, :GeomFromText_2)'',
> 4326)' WHERE id = 1

from what you are showing here, nothing appears wrong with your  
expression construct, although the contents of the "wkt" variable are  
suspect here.  The SQL output you illustrate has many differences from  
what a SQLAlchemy-supplied dialect would generate so is not very  
helpful in diagnosing your issue.

It would be helpful if you could provide a specific test case which  
reproduces your issue, including whatever third party extensions might  
be in use, so that we might see what other things might be going on.    
For example, here's an example of your exact expression, illustrating  
the correct SQL output using the Postgres dialect - tested with 0.4.6,  
0.4.7p1:

from sqlalchemy import *

engine = create_engine('postgres://')

mytable = Table("mytable", MetaData(engine),
     Column('id', Integer, primary_key=True),
     Column('geocolumn', String),
)

print mytable.update(mytable.c.id==1, {'geocolumn':  
func.GeomFromText(2, 4326)})

returns:

UPDATE mytable SET geocolumn=GeomFromText(%(GeomFromText_1)s, % 
(GeomFromText_2)s) WHERE mytable.id = %(id_1)s




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

Reply via email to