@@ -33,8 +33,8 @@ class TestCase(test_env.BaseTestCase):
33
33
34
34
def test_1300_bind_cursor (self ):
35
35
"1300 - test binding in a cursor"
36
- cursor = self .connection .cursor ()
37
- self .assertEqual (cursor .description , None )
36
+ cursor = self .conn .cursor ()
37
+ self .assertIsNone (cursor .description )
38
38
self .cursor .execute ("""
39
39
begin
40
40
open :cursor for select 'X' StringValue from dual;
@@ -50,8 +50,8 @@ def test_1300_bind_cursor(self):
50
50
51
51
def test_1301_bind_cursor_in_package (self ):
52
52
"1301 - test binding in a cursor from a package"
53
- cursor = self .connection .cursor ()
54
- self .assertEqual (cursor .description , None )
53
+ cursor = self .conn .cursor ()
54
+ self .assertIsNone (cursor .description )
55
55
self .cursor .callproc ("pkg_TestRefCursors.TestOutCursor" , (2 , cursor ))
56
56
varchar_ratio , nvarchar_ratio = test_env .get_charset_ratios ()
57
57
expected_value = [
@@ -64,7 +64,7 @@ def test_1301_bind_cursor_in_package(self):
64
64
65
65
def test_1302_bind_self (self ):
66
66
"1302 - test that binding the cursor itself is not supported"
67
- cursor = self .connection .cursor ()
67
+ cursor = self .conn .cursor ()
68
68
sql = """
69
69
begin
70
70
open :pcursor for
@@ -75,7 +75,7 @@ def test_1302_bind_self(self):
75
75
76
76
def test_1303_execute_after_close (self ):
77
77
"1303 - test returning a ref cursor after closing it"
78
- out_cursor = self .connection .cursor ()
78
+ out_cursor = self .conn .cursor ()
79
79
sql = """
80
80
begin
81
81
open :pcursor for
@@ -86,7 +86,7 @@ def test_1303_execute_after_close(self):
86
86
self .cursor .execute (sql , pcursor = out_cursor )
87
87
rows = out_cursor .fetchall ()
88
88
out_cursor .close ()
89
- out_cursor = self .connection .cursor ()
89
+ out_cursor = self .conn .cursor ()
90
90
self .cursor .execute (sql , pcursor = out_cursor )
91
91
rows2 = out_cursor .fetchall ()
92
92
self .assertEqual (rows , rows2 )
@@ -110,94 +110,93 @@ def test_1304_fetch_cursor(self):
110
110
111
111
def test_1305_ref_cursor_binds (self ):
112
112
"1305 - test that ref cursor binds cannot use optimised path"
113
- ref_cursor = self .connection .cursor ()
113
+ ref_cursor = self .conn .cursor ()
114
114
sql = """
115
115
begin
116
116
open :rcursor for
117
117
select IntCol, StringCol
118
118
from TestStrings where IntCol
119
119
between :start_value and :end_value;
120
120
end;"""
121
- self .cursor .execute (sql , rcursor = ref_cursor , start_value = 2 ,
122
- end_value = 4 )
123
121
expected_value = [
124
122
(2 , 'String 2' ),
125
123
(3 , 'String 3' ),
126
124
(4 , 'String 4' )
127
125
]
128
- rows = ref_cursor .fetchall ()
126
+ self .cursor .execute (sql , rcursor = ref_cursor , start_value = 2 ,
127
+ end_value = 4 )
128
+ self .assertEqual (ref_cursor .fetchall (), expected_value )
129
129
ref_cursor .close ()
130
- self .assertEqual (rows , expected_value )
131
- ref_cursor = self .connection .cursor ()
132
- self .cursor .execute (sql , rcursor = ref_cursor , start_value = 5 ,
133
- end_value = 6 )
130
+
134
131
expected_value = [
135
132
(5 , 'String 5' ),
136
133
(6 , 'String 6' )
137
134
]
138
- rows = ref_cursor .fetchall ()
139
- self .assertEqual (rows , expected_value )
135
+ ref_cursor = self .conn .cursor ()
136
+ self .cursor .execute (sql , rcursor = ref_cursor , start_value = 5 ,
137
+ end_value = 6 )
138
+ self .assertEqual (ref_cursor .fetchall (), expected_value )
140
139
141
140
def test_1306_refcursor_round_trips (self ):
142
141
"1306 - test round trips using a REF cursor"
143
142
self .setup_round_trip_checker ()
144
143
145
144
# simple DDL only requires a single round trip
146
- with self .connection .cursor () as cursor :
145
+ with self .conn .cursor () as cursor :
147
146
cursor .execute ("truncate table TestTempTable" )
148
147
self .assertRoundTrips (1 )
149
148
150
149
# array execution only requires a single round trip
151
150
num_rows = 590
152
- with self .connection .cursor () as cursor :
151
+ with self .conn .cursor () as cursor :
153
152
sql = "insert into TestTempTable (IntCol) values (:1)"
154
153
data = [(n + 1 ,) for n in range (num_rows )]
155
154
cursor .executemany (sql , data )
156
155
self .assertRoundTrips (1 )
157
156
158
157
# create REF cursor and execute stored procedure
159
158
# (array size set before procedure is called)
160
- with self .connection .cursor () as cursor :
161
- refcursor = self .connection .cursor ()
159
+ with self .conn .cursor () as cursor :
160
+ refcursor = self .conn .cursor ()
162
161
refcursor .arraysize = 150
163
162
cursor .callproc ("myrefcursorproc" , [refcursor ])
164
163
refcursor .fetchall ()
165
164
self .assertRoundTrips (5 )
166
165
167
166
# create REF cursor and execute stored procedure
168
167
# (array size set after procedure is called)
169
- with self .connection .cursor () as cursor :
170
- refcursor = self .connection .cursor ()
168
+ with self .conn .cursor () as cursor :
169
+ refcursor = self .conn .cursor ()
171
170
cursor .callproc ("myrefcursorproc" , [refcursor ])
172
171
refcursor .arraysize = 145
173
172
refcursor .fetchall ()
174
173
self .assertRoundTrips (6 )
175
174
176
175
def test_1307_refcursor_execute_different_sql (self ):
177
176
"1307 - test executing different SQL after getting a REF cursor"
178
- with self .connection .cursor () as cursor :
179
- refcursor = self .connection .cursor ()
177
+ with self .conn .cursor () as cursor :
178
+ refcursor = self .conn .cursor ()
180
179
cursor .callproc ("myrefcursorproc" , [refcursor ])
181
180
var = cursor .var (int )
182
181
refcursor .execute ("begin :1 := 15; end;" , [var ])
183
182
self .assertEqual (var .getvalue (), 15 )
184
183
185
184
def test_1308_function_with_ref_cursor_return (self ):
186
185
"1308 - test calling a function that returns a REF cursor"
187
- with self .connection .cursor () as cursor :
186
+ with self .conn .cursor () as cursor :
188
187
ref_cursor = cursor .callfunc ("pkg_TestRefCursors.TestReturnCursor" ,
189
188
oracledb .DB_TYPE_CURSOR , [2 ])
190
- rows = ref_cursor .fetchall ()
191
- self . assertEqual ( rows , [(1 , 'String 1' ), (2 , 'String 2' )])
189
+ self . assertEqual ( ref_cursor .fetchall (),
190
+ [(1 , 'String 1' ), (2 , 'String 2' )])
192
191
193
192
def test_1309_output_type_handler_with_ref_cursor (self ):
194
193
"1309 - test using an output type handler with a REF cursor"
195
194
def type_handler (cursor , metadata ):
196
195
return cursor .var (str , arraysize = cursor .arraysize )
197
- self .connection .outputtypehandler = type_handler
196
+ self .conn .outputtypehandler = type_handler
198
197
var = self .cursor .var (oracledb .DB_TYPE_CURSOR )
199
198
string_val = "Test String - 1309"
200
- with self .connection .cursor () as cursor :
199
+ with self .conn .cursor () as cursor :
201
200
cursor .callproc ("pkg_TestRefCursors.TestLobCursor" ,
202
201
[string_val , var ])
203
202
ref_cursor = var .getvalue ()
@@ -314,7 +313,7 @@ def test_1313_fetch_nested_cursors_with_more_cols_than_parent(self):
314
313
def test_1314_reuse_closed_ref_cursor_with_different_sql (self ):
315
314
"1314 - test reusing a closed ref cursor for executing different sql"
316
315
sql = "select 13141, 'String 13141' from dual"
317
- ref_cursor = self .connection .cursor ()
316
+ ref_cursor = self .conn .cursor ()
318
317
ref_cursor .prefetchrows = 0
319
318
ref_cursor .execute (sql )
320
319
plsql = "begin pkg_TestRefCursors.TestCloseCursor(:rcursor); end;"
@@ -326,7 +325,7 @@ def test_1314_reuse_closed_ref_cursor_with_different_sql(self):
326
325
def test_1315_reuse_closed_ref_cursor_with_same_sql (self ):
327
326
"1315 - test reusing a closed ref cursor for executing same sql"
328
327
sql = "select 1315, 'String 1315' from dual"
329
- ref_cursor = self .connection .cursor ()
328
+ ref_cursor = self .conn .cursor ()
330
329
ref_cursor .prefetchrows = 0
331
330
ref_cursor .execute (sql )
332
331
plsql = "begin pkg_TestRefCursors.TestCloseCursor(:rcursor); end;"
0 commit comments