diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-10-23 01:06:24 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-10-23 01:57:48 +0100 |
| commit | 8fb0f694f755a5c1bfdd67f923ec43be3c0d34b5 (patch) | |
| tree | 004da29b7091b6fcab16c619e19a92162c9c67b6 /tests | |
| parent | 05f9e231a0aafed57b1f38ad6a1e6a5838b05cc5 (diff) | |
| download | psycopg2-fix-794.tar.gz | |
Don't barf on Composite passed to execute_values()fix-794
Close #794
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_fast_executemany.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_fast_executemany.py b/tests/test_fast_executemany.py index 3eb19fa..94e5c3e 100755 --- a/tests/test_fast_executemany.py +++ b/tests/test_fast_executemany.py @@ -83,6 +83,16 @@ class TestExecuteBatch(FastExecuteTestMixin, testutils.ConnectingTestCase): cur.execute("select id, val from testfast order by id") self.assertEqual(cur.fetchall(), [(i, i * 10) for i in range(1000)]) + def test_composed(self): + from psycopg2 import sql + cur = self.conn.cursor() + psycopg2.extras.execute_batch(cur, + sql.SQL("insert into {0} (id, val) values (%s, %s)") + .format(sql.Identifier('testfast')), + ((i, i * 10) for i in range(1000))) + cur.execute("select id, val from testfast order by id") + self.assertEqual(cur.fetchall(), [(i, i * 10) for i in range(1000)]) + def test_pages(self): cur = self.conn.cursor() psycopg2.extras.execute_batch(cur, @@ -169,6 +179,16 @@ class TestExecuteValues(FastExecuteTestMixin, testutils.ConnectingTestCase): cur.execute("select id, val from testfast order by id") self.assertEqual(cur.fetchall(), [(i, i * 10) for i in range(1000)]) + def test_composed(self): + from psycopg2 import sql + cur = self.conn.cursor() + psycopg2.extras.execute_values(cur, + sql.SQL("insert into {0} (id, val) values %s") + .format(sql.Identifier('testfast')), + ((i, i * 10) for i in range(1000))) + cur.execute("select id, val from testfast order by id") + self.assertEqual(cur.fetchall(), [(i, i * 10) for i in range(1000)]) + def test_pages(self): cur = self.conn.cursor() psycopg2.extras.execute_values(cur, |
