On Wed, Sep 24, 2008 at 7:37 PM, Michael Bayer <[EMAIL PROTECTED]>wrote:

> we can of course add more functions to the list of "known" functions
> such as ifnull() (it would be best if ifnull() is a SQL standard
> function, I'm not sure if it is).
>
>
Not sure this will work for IFNULL since it's type depends upon the runtime
arguments.  I missed the func type_ argument when I read the documentation.
That is a good solution for the general case of specifiying the type when it
cannot be determined from the function or the function arguments.  In fact
I'm going to use it any time the type is not obvious.

For what it is worth the following patch modifies ResultProxy to convert
strings to unicode if convert_unicode == True.  It 'fixes' my example and
test/testall.py still passes.

[EMAIL PROTECTED]:~/Projects/sqlalchemy$ svn diff
Index: lib/sqlalchemy/engine/base.py
===================================================================
--- lib/sqlalchemy/engine/base.py    (revision 5123)
+++ lib/sqlalchemy/engine/base.py    (working copy)
@@ -1630,7 +1630,10 @@
         if processor:
             return processor(row[index])
         else:
-            return row[index]
+            result = row[index]
+            if isinstance(result, str) and
self.context.dialect.convert_unicode:
+                result = result.decode(self.context.dialect.encoding)
+            return result

     def _fetchone_impl(self):
         return self.cursor.fetchone()
[EMAIL PROTECTED]:~/Projects/sqlalchemy$

Thanks,


Shawn

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