@@ -28,11 +28,24 @@ const oracledb = require('oracledb');
2828const should = require ( 'should' ) ;
2929const assert = require ( 'assert' ) ;
3030const dbconfig = require ( './dbconfig.js' ) ;
31+ const testsUtil = require ( './testsUtil.js' ) ;
3132
3233describe ( "147. prefetchRows.js" , function ( ) {
3334
3435 let conn ;
3536
37+ const sql = `
38+ select 1, 'String 1' from dual
39+ union all
40+ select 2, 'String 2' from dual
41+ union all
42+ select 3, 'String 3' from dual
43+ union all
44+ select 4, 'String 4' from dual
45+ union all
46+ select 5, 'String 5' from dual
47+ order by 1` ;
48+
3649 const DefaultPrefetchRows = oracledb . prefetchRows ;
3750 before ( async ( ) => {
3851 try {
@@ -236,4 +249,58 @@ describe("147. prefetchRows.js", function() {
236249 }
237250 } ) ;
238251
239- } ) ;
252+ it ( '147.15 Query round-trips with no prefetch' , async ( ) => {
253+ if ( ! dbconfig . test . DBA_PRIVILEGE ) {
254+ return ;
255+ }
256+ try {
257+ const sid = await testsUtil . getSid ( conn ) ;
258+ let rt = await testsUtil . getRoundTripCount ( sid ) ;
259+
260+ await conn . execute ( sql , [ ] , { prefetchRows : 0 } ) ;
261+ rt = await testsUtil . getRoundTripCount ( sid ) - rt ;
262+
263+ should . strictEqual ( rt , 2 ) ;
264+
265+ } catch ( error ) {
266+ should . not . exist ( error ) ;
267+ }
268+ } ) ;
269+
270+ it ( '147.16 Query round-trips with prefetch equal to row count' , async ( ) => {
271+ if ( ! dbconfig . test . DBA_PRIVILEGE ) {
272+ return ;
273+ }
274+ try {
275+ const sid = await testsUtil . getSid ( conn ) ;
276+ let rt = await testsUtil . getRoundTripCount ( sid ) ;
277+
278+ await conn . execute ( sql , [ ] , { prefetchRows : 5 } ) ;
279+ rt = await testsUtil . getRoundTripCount ( sid ) - rt ;
280+
281+ should . strictEqual ( rt , 2 ) ;
282+
283+ } catch ( error ) {
284+ should . not . exist ( error ) ;
285+ }
286+ } ) ;
287+
288+ it ( '147.16 Query round-trips with prefetch larger than row count' , async ( ) => {
289+ if ( ! dbconfig . test . DBA_PRIVILEGE ) {
290+ return ;
291+ }
292+ try {
293+ const sid = await testsUtil . getSid ( conn ) ;
294+ let rt = await testsUtil . getRoundTripCount ( sid ) ;
295+
296+ await conn . execute ( sql , [ ] , { prefetchRows : 6 } ) ;
297+ rt = await testsUtil . getRoundTripCount ( sid ) - rt ;
298+
299+ should . strictEqual ( rt , 1 ) ;
300+
301+ } catch ( error ) {
302+ should . not . exist ( error ) ;
303+ }
304+ } ) ;
305+
306+ } ) ;
0 commit comments