array_accum

Issue #913 resolved
Former user created an issue

Hello,

I use the array_accum function of PostgreSQL quite frequently and I noticed a small problem (bug ?) when convert_unicode is set to True on the engine layer. The result of an array_accum is converted to a Python list (by the psycopg2 driver I guess). The problem is that if you have a text column (char, varchar, ...), and thus the output is a list of strings in this case, those strings are not of type unicode, but of type str, for example :

>>> select([t.c.name](t.c.name)).execute().fetchone()
(u'Poisson-chat am\xe9ricain',)

>>> select([func.array_accum(t.c.name)](func.array_accum(t.c.name))).execute().fetchone()
([am\xc3\xa9ricain', 'Gib\xc3\xa8le', ...]('Poisson-chat),)

This is a bit problematic because you have to take this into account when you write things (and thus add an additional test). I tried type_=PGArray(Unicode) in the func() but the result is the same

Comments (4)

  1. Mike Bayer repo owner
    • assigned issue to

    hoping ants has time to take a look at this, otherwise we'll try to get around to it.

  2. Former user Account Deleted

    (original author: ants) Oh, and for the func.array_accum case you'll still need the type_=PGArray(Unicode) param because SQLAlchemy doesn't know the return type of the function otherwise.

  3. Log in to comment