Author: cito
Date: Wed Aug 10 09:57:50 2016
New Revision: 883

Log:
Fix issue with adaptation of empty arrays in pg

Modified:
   trunk/docs/contents/changelog.rst
   trunk/pg.py
   trunk/tests/test_classic_dbwrapper.py

Modified: trunk/docs/contents/changelog.rst
==============================================================================
--- trunk/docs/contents/changelog.rst   Thu Jul 28 04:27:17 2016        (r882)
+++ trunk/docs/contents/changelog.rst   Wed Aug 10 09:57:50 2016        (r883)
@@ -15,6 +15,7 @@
   on the mailing list by Justin Pryzby).
 - Allow extra values that are not used in the command in the parameter dict
   passed to the query_formatted() method (as suggested by Justin Pryzby).
+- Improved handling of empty arrays in the classic module.
 - Unused classic connections were not properly garbage collected which could
   cause memory leaks (reported by Justin Pryzby).
 - Made C extension compatible with MSVC 9 again (this was needed to compile for

Modified: trunk/pg.py
==============================================================================
--- trunk/pg.py Thu Jul 28 04:27:17 2016        (r882)
+++ trunk/pg.py Wed Aug 10 09:57:50 2016        (r883)
@@ -517,7 +517,7 @@
         if isinstance(value, (date, time, datetime, timedelta)):
             return 'date'
         if isinstance(value, list):
-            return '%s[]' % cls.guess_simple_base_type(value)
+            return '%s[]' % (cls.guess_simple_base_type(value) or 'text',)
         if isinstance(value, tuple):
             simple_type = cls.simple_type
             typ = simple_type('record')

Modified: trunk/tests/test_classic_dbwrapper.py
==============================================================================
--- trunk/tests/test_classic_dbwrapper.py       Thu Jul 28 04:27:17 2016        
(r882)
+++ trunk/tests/test_classic_dbwrapper.py       Wed Aug 10 09:57:50 2016        
(r883)
@@ -929,6 +929,18 @@
         r = q.getresult()[0][0]
         self.assertEqual(r, 'alphabetagammadeltaepsilon')
 
+    def testQueryFormattedWithAny(self):
+        f = self.db.query_formatted
+        q = "select 2 = any(%s)"
+        r = f(q, [[1, 3]]).getresult()[0][0]
+        self.assertEqual(r, False if pg.get_bool() else 'f')
+        r = f(q, [[1, 2, 3]]).getresult()[0][0]
+        self.assertEqual(r, True if pg.get_bool() else 't')
+        r = f(q, [[]]).getresult()[0][0]
+        self.assertEqual(r, False if pg.get_bool() else 'f')
+        r = f(q, [[None]]).getresult()[0][0]
+        self.assertIsNone(r)
+
     def testPkey(self):
         query = self.db.query
         pkey = self.db.pkey
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to