Mike Bayer avatar Mike Bayer committed fc3343b

- [bug] Fixed bug affecting Py3K whereby
string positional parameters passed to
engine/connection execute() would fail to be
interpreted correctly, due to __iter__
being present on Py3K string.
[ticket:2503].

Comments (0)

Files changed (4)

     The most prominently affected DBAPI
     is pyodbc.  [ticket:2489]
 
+  - [bug] Fixed bug affecting Py3K whereby
+    string positional parameters passed to 
+    engine/connection execute() would fail to be
+    interpreted correctly, due to __iter__
+    being present on Py3K string.  
+    [ticket:2503].
+
 - oracle
   - [bug] Added ROWID to oracle.*, [ticket:2483]
 

lib/sqlalchemy/engine/base.py

         elif len(multiparams) == 1:
             zero = multiparams[0]
             if isinstance(zero, (list, tuple)):
-                if not zero or hasattr(zero[0], '__iter__'):
+                if not zero or isinstance(zero[0], (list, tuple, dict)):
                     return zero
                 else:
                     return [zero]
             else:
                 return [[zero]]
         else:
-            if hasattr(multiparams[0], '__iter__'):
+            if isinstance(multiparams[0], (list, tuple, dict)):
                 return multiparams
             else:
                 return [multiparams]

test/aaa_profiling/test_zoomark.py

     def test_profile_2_insert(self):
         self.test_baseline_2_insert()
 
-    @profiling.function_call_count(3340, {'2.4': 2158, '2.7':3541, 
-                                        '2.7+cextension':3317, '2.6':3564})
+    @profiling.function_call_count(3333, {'2.4': 2358})
     def test_profile_3_properties(self):
         self.test_baseline_3_properties()
 

test/engine/test_execute.py

                 (6, 'donkey'),
                 (7, 'sally'),
                 ]
+            for multiparam, param in [
+                (("jack", "fred"), {}),
+                ((["jack", "fred"],), {})
+            ]:
+                res = conn.execute(
+                    "select * from users where user_name=? or "
+                    "user_name=? order by user_id", 
+                    *multiparam, **param)
+                assert res.fetchall() == [
+                    (1, 'jack'),
+                    (2, 'fred')
+                ]
+            res = conn.execute("select * from users where user_name=?",
+                "jack"
+            )
+            assert res.fetchall() == [(1, 'jack')]
             conn.execute('delete from users')
 
         go(testing.db)
             res = conn.execute('select * from users order by user_id')
             assert res.fetchall() == [(1, 'jack'), (2, 'ed'), (3,
                     'horse'), (4, 'sally'), (5, None)]
+            for multiparam, param in [
+                (("jack", "ed"), {}),
+                ((["jack", "ed"],), {})
+            ]:
+                res = conn.execute(
+                    "select * from users where user_name=%s or "
+                    "user_name=%s order by user_id", 
+                    *multiparam, **param)
+                assert res.fetchall() == [
+                    (1, 'jack'),
+                    (2, 'ed')
+                ]
+            res = conn.execute("select * from users where user_name=%s",
+                "jack"
+            )
+            assert res.fetchall() == [(1, 'jack')]
+
             conn.execute('delete from users')
         go(testing.db)
         conn = testing.db.connect()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.