|
1 | 1 | #------------------------------------------------------------------------------
|
2 |
| -# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. |
| 2 | +# Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. |
3 | 3 | #
|
4 | 4 | # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
|
5 | 5 | #
|
|
14 | 14 | import test_env
|
15 | 15 | import cx_Oracle as oracledb
|
16 | 16 | import decimal
|
| 17 | +import datetime |
17 | 18 |
|
18 | 19 | class TestCase(test_env.BaseTestCase):
|
19 | 20 |
|
@@ -933,5 +934,51 @@ def test_1278_execute_with_incorrect_bind_values(self):
|
933 | 934 | self.assertRaises(oracledb.DatabaseError, self.cursor.execute,
|
934 | 935 | statement, value=var, value2=var, value3=var)
|
935 | 936 |
|
| 937 | + def test_1279_change_in_size_on_successive_bind(self): |
| 938 | + "1279 - change in size on subsequent binds does not use optimised path" |
| 939 | + self.cursor.execute("truncate table TestTempTable") |
| 940 | + data = [ |
| 941 | + (1, "Test String #1"), |
| 942 | + (2, "ABC" * 100) |
| 943 | + ] |
| 944 | + sql = "insert into TestTempTable (IntCol, StringCol) values (:1, :2)" |
| 945 | + for row in data: |
| 946 | + self.cursor.execute(sql, row) |
| 947 | + self.connection.commit() |
| 948 | + self.cursor.execute("select IntCol, StringCol from TestTempTable") |
| 949 | + self.assertEqual(self.cursor.fetchall(), data) |
| 950 | + |
| 951 | + def test_1280_change_in_type_on_successive_bind(self): |
| 952 | + "1280 - change in type on subsequent binds cannot use optimised path" |
| 953 | + sql = "select :1 from dual" |
| 954 | + self.cursor.execute(sql, ('W',)) |
| 955 | + row, = self.cursor.fetchone() |
| 956 | + self.assertEqual(row, 'W') |
| 957 | + self.cursor.execute(sql, ('S',)) |
| 958 | + row, = self.cursor.fetchone() |
| 959 | + self.assertEqual(row, 'S') |
| 960 | + self.cursor.execute(sql, (7,)) |
| 961 | + row, = self.cursor.fetchone() |
| 962 | + self.assertEqual(row, '7') |
| 963 | + |
| 964 | + def test_1281_dml_can_use_optimised_path(self): |
| 965 | + "1281 - test that dml can use optimised path" |
| 966 | + data_to_insert = [ |
| 967 | + (1, "Test String #1"), |
| 968 | + (2, "Test String #2"), |
| 969 | + (3, "Test String #3") |
| 970 | + ] |
| 971 | + self.cursor.execute("truncate table TestTempTable") |
| 972 | + sql = "insert into TestTempTable (IntCol, StringCol) values (:1, :2)" |
| 973 | + for row in data_to_insert: |
| 974 | + with self.connection.cursor() as cursor: |
| 975 | + cursor.execute(sql, row) |
| 976 | + self.connection.commit() |
| 977 | + self.cursor.execute(""" |
| 978 | + select IntCol, StringCol |
| 979 | + from TestTempTable |
| 980 | + order by IntCol""") |
| 981 | + self.assertEqual(self.cursor.fetchall(), data_to_insert) |
| 982 | + |
936 | 983 | if __name__ == "__main__":
|
937 | 984 | test_env.run_test_cases()
|
0 commit comments