]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [bug] Fixed bug affecting Py3K whereby
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Jun 2012 00:11:05 +0000 (20:11 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Jun 2012 00:11:05 +0000 (20:11 -0400)
string positional parameters passed to
engine/connection execute() would fail to be
interpreted correctly, due to __iter__
being present on Py3K string.
[ticket:2503].  Also in 0.7.8.

CHANGES
lib/sqlalchemy/engine/base.py
test/aaa_profiling/test_zoomark.py
test/engine/test_execute.py

diff --git a/CHANGES b/CHANGES
index c29ea98a451eedcb7c85975ca88640e7d8078e9a..947395fd9216998ca810e973b4e3e9a819469914 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -210,6 +210,13 @@ CHANGES
     The most prominently affected DBAPI
     is pyodbc.  Also in 0.7.8.  [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].  Also in 0.7.8.
+
   - [feature] Added a new system
     for registration of new dialects in-process
     without using an entrypoint.  See the
index f68c31b974285f4d7c1f9eeeb683eafb24153c4f..2e05f532c4e9e908faa345b678c37bad525a8255 100644 (file)
@@ -1476,7 +1476,7 @@ class Connection(Connectable):
         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]
@@ -1485,7 +1485,7 @@ class Connection(Connectable):
             else:
                 return [[zero]]
         else:
-            if hasattr(multiparams[0], '__iter__'):
+            if isinstance(multiparams[0], (list, tuple, dict)):
                 return multiparams
             else:
                 return [multiparams]
index e1bee2b987b8e98b0262a9c665ad3f58a1d965c1..e3ce8d078e4373b507f852cc34e381e57a9e5346 100644 (file)
@@ -377,8 +377,7 @@ class ZooMarkTest(fixtures.TestBase):
     def test_profile_2_insert(self):
         self.test_baseline_2_insert()
 
-    @profiling.function_call_count(3118, {'2.7':3109, 
-                                        '2.7+cextension':3109, '2.6':3109})
+    @profiling.function_call_count(3333)
     def test_profile_3_properties(self):
         self.test_baseline_3_properties()
 
index 610f5e42b0b88d50ce305a92cde3962a14c7bfdb..7ccd42b73f2943af13b95fe692c5070ee641fb0a 100644 (file)
@@ -79,6 +79,22 @@ class ExecuteTest(fixtures.TestBase):
                 (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)
@@ -104,6 +120,23 @@ class ExecuteTest(fixtures.TestBase):
             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()