Commits

Anonymous committed f9c90b4

fix not calling the result processor of PGArray subtypes. (a rather embarrasing copypaste error) [ticket:913]

Comments (0)

Files changed (3)

       loaded collection will get cleared out if it's referenced in more than
       one batch, and in all cases attributes will be overwritten on instances
       that occur in more than one batch.
-      
+
+- dialects
+
+    - PostgreSQL
+       - Fixed the missing call to subtype result processor for the PGArray
+         type. [ticket:913]
+
 0.4.2
 -----
 - sql

lib/sqlalchemy/databases/postgres.py

         return process
         
     def result_processor(self, dialect):
-        item_proc = self.item_type.bind_processor(dialect)
+        item_proc = self.item_type.result_processor(dialect)
         def process(value):
             if value is None:
                 return value

test/dialect/postgres.py

         arrtable = Table('arrtable', metadata,
             Column('id', Integer, primary_key=True),
             Column('intarr', postgres.PGArray(Integer)),
-            Column('strarr', postgres.PGArray(String), nullable=False)
+            Column('strarr', postgres.PGArray(String(convert_unicode=True)), nullable=False)
         )
         metadata.create_all()
     def tearDownAll(self):
         self.assertEquals(results[0][0], [1,2,3,4,5,6])
         arrtable.delete().execute()
 
+    def test_array_subtype_resultprocessor(self):
+        arrtable.insert().execute(intarr=[4,5,6], strarr=[[u'm\xe4\xe4'], [u'm\xf6\xf6']])
+        arrtable.insert().execute(intarr=[1,2,3], strarr=[u'm\xe4\xe4', u'm\xf6\xf6'])
+        results = arrtable.select(order_by=[arrtable.c.intarr]).execute().fetchall()
+        self.assertEquals(len(results), 2)
+        self.assertEquals(results[0]['strarr'], [u'm\xe4\xe4', u'm\xf6\xf6'])
+        self.assertEquals(results[1]['strarr'], [[u'm\xe4\xe4'], [u'm\xf6\xf6']])
+        arrtable.delete().execute()
+
 if __name__ == "__main__":
     testbase.main()