| 1 | from django.db import connection |
| 2 | from django.test import TestCase |
| 3 | |
| 4 | class CursorTests(TestCase): |
| 5 | def setUp(self): |
| 6 | cursor = connection.cursor() |
| 7 | query = 'create table test (Field1 NUMBER(11),Field2 NUMBER(11))' |
| 8 | cursor.execute(query) |
| 9 | |
| 10 | def testExecuteManyEmptyParams(self): |
| 11 | """ Test for bug 12612, removing the error suppression of 4765 """ |
| 12 | cursor = connection.cursor() |
| 13 | query = "insert into test (name) values(%s)" |
| 14 | try: |
| 15 | cursor.executemany(query, []) |
| 16 | self.fail("Should have raised an IndexError here!") |
| 17 | except IndexError: |
| 18 | pass |
| 19 | |
| 20 | def testExecuteManyStringFormatting(self): |
| 21 | """ Test for bug 4896 re: string formatting with executemany() """ |
| 22 | cursor = connection.cursor() |
| 23 | query = 'insert into test values (%s, %s)' |
| 24 | cursor.executemany(query, [(i,i+1) for i in range(1,100)]) |
| 25 | |
| 26 | def tearDown(self): |
| 27 | cursor = connection.cursor() |
| 28 | query = 'drop table test' |
| 29 | cursor.execute(query) |