On Jul 13, 6:17 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > The handling was changed in 0.6, but we specifically fixed a bunch of things > related to Decimal in 0.6.2. Oracle doesn't send entirely meaningful > information regarding the specifics of numeric types in a few cases > (typically they involve subqueries, it appears you've found another variant > of it), in those we return Decimal and let SQLA types handle further > conversion.
I upgraded from 0.6.1, so the changes in 0.6.2 are the ones that are affecting me. > Are you sure you were getting back integers before, and not floats, for this > particular statement ? I've observed that cx_oracle seems to choose float() > in the face of ambiguity. "print type (row.col)" produces "<type 'int'>". > > and I > > know that I can convert the data to integers when I reference the > > columns; however, I'd prefer to deal with the conversion closer to the > > source. Unfortunately, I can't figure out how to do that though I > > suspect it's pretty simple. > > if you use the Integer type, that will coerce values to integer. Yes, but where/how? :-) > > So, what's a good way to tell SA about the types of the columns > > returned by the query? > > it depends on what kind of query you are using. func() for example can be > made to return Integer by passing in type_, func.foo(type_=Integer). text() > handles it using result_map. Statements derived from Table just do the > right thing automatically. Its only if you use func()/text() with no return > type, or execute("string"), that the typing isn't taking place, so there is > always a way to get Integer in there. Okay, here's the general form that I'm currently using... t = "SELECT * FROM TABLE (myfunc (:a,:b))" q = session.query ('COL1", 'COL2", 'COL3').from_statement (t).params (a=v1,b=v2) Hm...your reference to "text()" above led me to this... t = text ("SELECT * FROM TABLE (myfunc (:a,:b))", typemap={'COL3': Integer}) q = session.query ('COL1", 'COL2", 'COL3').from_statement (t).params (a=v1,b=v2) That seems to do the trick. Thanks much. Rodney -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.