-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathfetchArraySize8.js
More file actions
364 lines (317 loc) · 14.1 KB
/
fetchArraySize8.js
File metadata and controls
364 lines (317 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
/******************************************************************************
*
* This software is dual-licensed to you under the Universal Permissive License
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
* either license.
*
* If you elect to accept the software under the Apache License, Version 2.0,
* the following applies:
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* NAME
* 155. fetchArraySize8.js
*
* DESCRIPTION
* Direct fetch (non-RS) tests querying CLOBs (for streaming) using different
* fetchArraySizes values & tablesizes
*
*****************************************************************************/
'use strict';
const oracledb = require('oracledb');
const assert = require ('assert');
const dbConfig = require('./dbconfig.js');
describe("155. fetchArraySize8.js", function() {
let connection = null;
const default_fetcArraySize = oracledb.fetchArraySize;
const default_maxRows = oracledb.maxRows;
const tableName = "nodb_fetchArraySize_155";
const create_table = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
" BEGIN \n" +
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
" EXCEPTION \n" +
" WHEN e_table_missing \n" +
" THEN NULL; \n" +
" END; \n" +
" EXECUTE IMMEDIATE (' \n" +
" CREATE TABLE " + tableName + " ( \n" +
" id NUMBER, \n" +
" content CLOB \n" +
" ) \n" +
" '); \n" +
"END; ";
const drop_table = "DROP TABLE " + tableName + " PURGE";
before(async function() {
connection = await oracledb.getConnection(dbConfig);
assert.strictEqual(default_fetcArraySize, 100);
assert.strictEqual(default_maxRows, 0);
});
after(async function() {
await connection.close();
});
describe("155.1 Streaming clobs with different oracledb.fetchArraySize", function() {
afterEach(function() {
oracledb.fetchArraySize = default_fetcArraySize;
oracledb.maxRows = default_maxRows;
});
const basicFetchWithGlobalOption = async function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID) {
await connection.execute(create_table);
await insertData(tableSize);
oracledb.fetchArraySize = fetchArraySizeVal;
oracledb.maxRows = maxRowsVal;
const result = await connection.execute(
"select * from " + tableName + " where id > " + affectedID + " order by id"
);
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
assert.strictEqual(result.rows.length, resultLenExpected);
await verifyResult(result.rows);
await connection.execute(drop_table);
};
it("155.1.1 maxRows > table size > oracledb.fetchArraySize", async function() {
const tableSize = 100;
const fetchArraySizeVal = tableSize / 2;
const maxRowsVal = tableSize * 2;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.2 maxRows > oracledb.fetchArraySize > table size", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize + 10;
const maxRowsVal = tableSize * 3;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.3 table size > maxRows > oracledb.fetchArraySize", async function() {
const tableSize = 199;
const fetchArraySizeVal = tableSize - 80;
const maxRowsVal = tableSize - 50;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.4 table size > oracledb.fetchArraySize > maxRow", async function() {
const tableSize = 290;
const fetchArraySizeVal = tableSize - 90;
const maxRowsVal = tableSize - 150;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.5 maxRows = oracledb.fetchArraySize < table size", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize - 3;
const maxRowsVal = fetchArraySizeVal;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.6 maxRows = oracledb.fetchArraySize = table size", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize;
const maxRowsVal = tableSize;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.7 maxRows = oracledb.fetchArraySize > table size", async function() {
const tableSize = 10;
const fetchArraySizeVal = tableSize + 30;
const maxRowsVal = fetchArraySizeVal;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.8 maxRows = oracledb.fetchArraySize/10", async function() {
const tableSize = 100;
const fetchArraySizeVal = 30;
const maxRowsVal = fetchArraySizeVal / 10;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
const tableSize = 2;
const fetchArraySizeVal = 30;
const maxRowsVal = fetchArraySizeVal * 10;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
const tableSize = 200;
const fetchArraySizeVal = tableSize / 10;
const maxRowsVal = fetchArraySizeVal + 50;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.11 maxRows = 0, fetchArraySize = table size ", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize;
const maxRowsVal = 0;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
const tableSize = 100;
const fetchArraySizeVal = tableSize;
const maxRowsVal = tableSize - 1;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.1.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize - 1;
const maxRowsVal = tableSize;
const affectedID = 0;
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
});
describe("155.2 Streaming clobs with different execute() option fetchArraySize", function() {
afterEach(function() {
oracledb.maxRows = default_maxRows;
});
const basicFetchWithExecOption = async function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID) {
await connection.execute(create_table);
await insertData(tableSize);
oracledb.maxRows = maxRowsVal;
const result = await connection.execute(
"select * from " + tableName + " where id > " + affectedID + " order by id",
[],
{
fetchArraySize: fetchArraySizeVal
}
);
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
assert.strictEqual(result.rows.length, resultLenExpected);
await verifyResult(result.rows);
};
it("155.2.1 maxRows > table size > oracledb.fetchArraySize", async function() {
const tableSize = 100;
const fetchArraySizeVal = tableSize - 50;
const maxRowsVal = tableSize + 200;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.2 maxRows > oracledb.fetchArraySize > table size", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize + 30;
const maxRowsVal = tableSize + 50;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.3 table size > maxRows > oracledb.fetchArraySize", async function() {
const tableSize = 199;
const fetchArraySizeVal = tableSize - 130;
const maxRowsVal = tableSize - 50;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.4 table size > oracledb.fetchArraySize > maxRow", async function() {
const tableSize = 290;
const fetchArraySizeVal = tableSize - 10;
const maxRowsVal = tableSize - 50;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.5 maxRows = oracledb.fetchArraySize < table size", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize - 3;
const maxRowsVal = fetchArraySizeVal;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.6 maxRows = oracledb.fetchArraySize = table size", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize;
const maxRowsVal = tableSize;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.7 maxRows = oracledb.fetchArraySize > table size", async function() {
const tableSize = 10;
const fetchArraySizeVal = tableSize + 30;
const maxRowsVal = fetchArraySizeVal;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.8 maxRows = oracledb.fetchArraySize/10", async function() {
const tableSize = 100;
const fetchArraySizeVal = 30;
const maxRowsVal = fetchArraySizeVal / 10;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
const tableSize = 2;
const fetchArraySizeVal = 30;
const maxRowsVal = fetchArraySizeVal * 10;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
const tableSize = 200;
const fetchArraySizeVal = tableSize / 10;
const maxRowsVal = fetchArraySizeVal + 50;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.11 maxRows = 0, fetchArraySize = table size ", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize;
const maxRowsVal = 0;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize;
const maxRowsVal = tableSize - 1;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
it("155.2.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
const tableSize = 20;
const fetchArraySizeVal = tableSize - 1;
const maxRowsVal = tableSize;
const affectedID = 0;
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
});
});
const insertData = async function(tableSize) {
const insert_data = "BEGIN \n" +
" FOR i IN 1.." + tableSize + " LOOP \n" +
" EXECUTE IMMEDIATE (' \n" +
" insert into " + tableName + " values (' || i || ',''CLOB' || to_char(i) || ''') \n" +
" '); \n" +
" END LOOP; \n" +
" commit; \n" +
"END; ";
await connection.execute(insert_data);
const result = await connection.execute(
"select id from " + tableName
);
assert.strictEqual(result.rows.length, tableSize);
};
const verifyResult = async function(rows) {
for (const row of rows) {
await verifyEachRow(row);
}
};
const verifyEachRow = async function(row) {
const id = row[0];
assert.strictEqual(row[0], id);
const lob = row[1];
const clobData = await lob.getData();
assert.strictEqual(clobData, "CLOB" + String(id));
};
});