[EMAIL PROTECTED] wrote:
res = enginedb.execute("""
 SELECT w2.id,
  (SELECT w2t.creation_date AS creation_date
   FROM wkstate AS w2t  where w2t.id=w2.id
   LIMIT 1 OFFSET 0)
 FROM wkstate AS w2
 """).fetchone()

print type(res[1]) => str
but creation_date is a DateTime type!


the above query you are issuing straight textual SQL.  SA has no clue
what types to return and it has no say in it - the inconsistent
behavior above originates within your database/DBAPI (which you havent
told me which one it is).

you can issue textual sql using the typemap parameter to text():

s = text("some sql", typemap={'x':types.DateTime})

I tried with the 'tagged' sqlalchemy query style, using label and typemap:
res = select([w2.c.id,  #w2 is an alias of the table
        select( ...).label('tmp')
       ).execute(typemap={'tmp':types.DateTime}).fetchall()

all kw arguments that you send to execute() are just bind
parameters..execute() doesnt take the "typemap" param as anything
special.  the text clause above should work better (or at least is
intended for this scenario).   also the type should be propigated
through the label() youre creating above, i thought perhaps it might
not but i added a test case in 2206 that shows it does.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to