@@ -119,48 +119,19 @@ async def test_cursor_fetch_all(
119
119
assert await cursor .fetchall () == []
120
120
121
121
@pytest .mark .asyncio
122
- async def test_cursor_next_set (
122
+ async def test_cursor_fetch_one_multiple_result_sets (
123
123
self , session : ydb .aio .QuerySession
124
124
) -> None :
125
125
async with ydb_dbapi .AsyncCursor (session = session ) as cursor :
126
- yql_text = """SELECT 1 as val; SELECT 2 as val;"""
127
- await cursor .execute (query = yql_text )
128
-
129
- res = await cursor .fetchall ()
130
- assert res is not None
131
- assert len (res ) == 1
132
- assert res [0 ][0 ] == 1
133
-
134
- nextset = await cursor .nextset ()
135
- assert nextset
136
-
137
- res = await cursor .fetchall ()
138
- assert res is not None
139
- assert len (res ) == 1
140
- assert res [0 ][0 ] == 2
141
-
142
- nextset = await cursor .nextset ()
143
- assert nextset
144
-
145
- assert await cursor .fetchall () == []
146
-
147
- nextset = await cursor .nextset ()
148
- assert not nextset
149
-
150
- @pytest .mark .asyncio
151
- async def test_cursor_fetch_one_autoscroll (
152
- self , session : ydb .aio .QuerySession
153
- ) -> None :
154
- async with ydb_dbapi .AsyncCursor (
155
- session = session , auto_scroll_result_sets = True
156
- ) as cursor :
157
126
yql_text = """
158
127
SELECT id, val FROM table;
159
128
SELECT id, val FROM table1;
160
129
SELECT id, val FROM table2;
161
130
"""
162
131
await cursor .execute (query = yql_text )
163
132
133
+ assert cursor .rowcount == 12
134
+
164
135
for i in range (RESULT_SET_LENGTH * RESULT_SET_COUNT ):
165
136
res = await cursor .fetchone ()
166
137
assert res is not None
@@ -170,19 +141,19 @@ async def test_cursor_fetch_one_autoscroll(
170
141
assert not await cursor .nextset ()
171
142
172
143
@pytest .mark .asyncio
173
- async def test_cursor_fetch_many_autoscroll (
144
+ async def test_cursor_fetch_many_multiple_result_sets (
174
145
self , session : ydb .aio .QuerySession
175
146
) -> None :
176
- async with ydb_dbapi .AsyncCursor (
177
- session = session , auto_scroll_result_sets = True
178
- ) as cursor :
147
+ async with ydb_dbapi .AsyncCursor (session = session ) as cursor :
179
148
yql_text = """
180
149
SELECT id, val FROM table;
181
150
SELECT id, val FROM table1;
182
151
SELECT id, val FROM table2;
183
152
"""
184
153
await cursor .execute (query = yql_text )
185
154
155
+ assert cursor .rowcount == 12
156
+
186
157
halfsize = (RESULT_SET_LENGTH * RESULT_SET_COUNT ) // 2
187
158
for _ in range (2 ):
188
159
res = await cursor .fetchmany (size = halfsize )
@@ -193,19 +164,19 @@ async def test_cursor_fetch_many_autoscroll(
193
164
assert not await cursor .nextset ()
194
165
195
166
@pytest .mark .asyncio
196
- async def test_cursor_fetch_all_autoscroll (
167
+ async def test_cursor_fetch_all_multiple_result_sets (
197
168
self , session : ydb .aio .QuerySession
198
169
) -> None :
199
- async with ydb_dbapi .AsyncCursor (
200
- session = session , auto_scroll_result_sets = True
201
- ) as cursor :
170
+ async with ydb_dbapi .AsyncCursor (session = session ) as cursor :
202
171
yql_text = """
203
172
SELECT id, val FROM table;
204
173
SELECT id, val FROM table1;
205
174
SELECT id, val FROM table2;
206
175
"""
207
176
await cursor .execute (query = yql_text )
208
177
178
+ assert cursor .rowcount == 12
179
+
209
180
res = await cursor .fetchall ()
210
181
211
182
assert len (res ) == RESULT_SET_COUNT * RESULT_SET_LENGTH
@@ -274,45 +245,19 @@ def test_cursor_fetch_all(self, session_sync: ydb.QuerySession) -> None:
274
245
275
246
assert cursor .fetchall () == []
276
247
277
- def test_cursor_next_set (self , session_sync : ydb .QuerySession ) -> None :
278
- with ydb_dbapi .Cursor (session = session_sync ) as cursor :
279
- yql_text = """SELECT 1 as val; SELECT 2 as val;"""
280
- cursor .execute (query = yql_text )
281
-
282
- res = cursor .fetchall ()
283
- assert res is not None
284
- assert len (res ) == 1
285
- assert res [0 ][0 ] == 1
286
-
287
- nextset = cursor .nextset ()
288
- assert nextset
289
-
290
- res = cursor .fetchall ()
291
- assert res is not None
292
- assert len (res ) == 1
293
- assert res [0 ][0 ] == 2
294
-
295
- nextset = cursor .nextset ()
296
- assert nextset
297
-
298
- assert cursor .fetchall () == []
299
-
300
- nextset = cursor .nextset ()
301
- assert not nextset
302
-
303
- def test_cursor_fetch_one_autoscroll (
248
+ def test_cursor_fetch_one_multiple_result_sets (
304
249
self , session_sync : ydb .QuerySession
305
250
) -> None :
306
- with ydb_dbapi .Cursor (
307
- session = session_sync , auto_scroll_result_sets = True
308
- ) as cursor :
251
+ with ydb_dbapi .Cursor (session = session_sync ) as cursor :
309
252
yql_text = """
310
253
SELECT id, val FROM table;
311
254
SELECT id, val FROM table1;
312
255
SELECT id, val FROM table2;
313
256
"""
314
257
cursor .execute (query = yql_text )
315
258
259
+ assert cursor .rowcount == 12
260
+
316
261
for i in range (RESULT_SET_LENGTH * RESULT_SET_COUNT ):
317
262
res = cursor .fetchone ()
318
263
assert res is not None
@@ -321,19 +266,19 @@ def test_cursor_fetch_one_autoscroll(
321
266
assert cursor .fetchone () is None
322
267
assert not cursor .nextset ()
323
268
324
- def test_cursor_fetch_many_autoscroll (
269
+ def test_cursor_fetch_many_multiple_result_sets (
325
270
self , session_sync : ydb .QuerySession
326
271
) -> None :
327
- with ydb_dbapi .Cursor (
328
- session = session_sync , auto_scroll_result_sets = True
329
- ) as cursor :
272
+ with ydb_dbapi .Cursor (session = session_sync ) as cursor :
330
273
yql_text = """
331
274
SELECT id, val FROM table;
332
275
SELECT id, val FROM table1;
333
276
SELECT id, val FROM table2;
334
277
"""
335
278
cursor .execute (query = yql_text )
336
279
280
+ assert cursor .rowcount == 12
281
+
337
282
halfsize = (RESULT_SET_LENGTH * RESULT_SET_COUNT ) // 2
338
283
for _ in range (2 ):
339
284
res = cursor .fetchmany (size = halfsize )
@@ -343,19 +288,19 @@ def test_cursor_fetch_many_autoscroll(
343
288
assert cursor .fetchmany (2 ) == []
344
289
assert not cursor .nextset ()
345
290
346
- def test_cursor_fetch_all_autoscroll (
291
+ def test_cursor_fetch_all_multiple_result_sets (
347
292
self , session_sync : ydb .QuerySession
348
293
) -> None :
349
- with ydb_dbapi .Cursor (
350
- session = session_sync , auto_scroll_result_sets = True
351
- ) as cursor :
294
+ with ydb_dbapi .Cursor (session = session_sync ) as cursor :
352
295
yql_text = """
353
296
SELECT id, val FROM table;
354
297
SELECT id, val FROM table1;
355
298
SELECT id, val FROM table2;
356
299
"""
357
300
cursor .execute (query = yql_text )
358
301
302
+ assert cursor .rowcount == 12
303
+
359
304
res = cursor .fetchall ()
360
305
361
306
assert len (res ) == RESULT_SET_COUNT * RESULT_SET_LENGTH
0 commit comments