Skip to content

Commit e6581c6

Browse files
committed
Add another stream metadata event test
1 parent 35594e7 commit e6581c6

File tree

3 files changed

+133
-96
lines changed

3 files changed

+133
-96
lines changed

test/list.txt

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,25 @@ Overview of node-oracledb functional tests
165165
8.3 can also use the autoCommit for SELECTs feature
166166

167167
9. columnMetadata.js
168-
9.1 shows metaData correctly when retrieving 1 column from a 4-column table
169-
9.2 shows metaData when retrieving 2 columns. MetaData is correct in content and sequence
170-
9.3 shows metaData correctly when retrieve 3 columns
171-
9.4 shows metaData correctly when retrieving all columns with [SELECT * FROM table] statement
172-
9.5 works for SELECT count(*)
173-
9.6 works when a query returns no rows
174-
9.7 works for tables whose column names were created case sensitively
175-
9.8 only works for SELECT statement, does not work for INSERT
176-
9.9 only works for SELECT statement, does not work for UPDATE
177-
9.10 works with a large number of columns
178-
9.11 works with column names consisting of single characters
179-
9.12 works with a SQL WITH statement
168+
9.1 tests with the same table
169+
9.1.1 shows metaData correctly when retrieving 1 column from a 4-column table
170+
9.1.2 shows metaData when retrieving 2 columns. MetaData is correct in content and sequence
171+
9.1.3 shows metaData correctly when retrieve 3 columns
172+
9.1.4 shows metaData correctly when retrieving all columns with [SELECT * FROM table] statement
173+
9.1.5 works for SELECT count(*)
174+
9.1.6 works when a query returns no rows
175+
9.1.7 only works for SELECT statement, does not work for INSERT
176+
9.1.8 only works for SELECT statement, does not work for UPDATE
177+
9.1.9 works with a SQL WITH statement
178+
9.1.10 displays metaData correctly with result set
179+
9.2 case sensitive
180+
9.2.1 works for tables whose column names were created case sensitively
181+
9.3 Large number of columns
182+
9.10 works with a large number of columns
183+
9.4 single character column
184+
9.4.1 works with column names consisting of single characters
185+
9.5 duplicate column alias
186+
9.5.1 works when using duplicate column alias
180187

181188
10. nullColumnValues.js
182189
10.1 a simple query for null value
@@ -238,7 +245,7 @@ Overview of node-oracledb functional tests
238245
12.7.1 maxRows option is ignored when resultSet option is true
239246
12.7.2 maxRows option is ignored with REF Cursor
240247

241-
13. stream.js
248+
13. stream1.js
242249
13.1 Testing QueryStream
243250
13.1.1 stream results for oracle connection
244251
13.1.2 stream results for oracle connection (outFormat: oracledb.OBJECT)
@@ -257,18 +264,19 @@ Overview of node-oracledb functional tests
257264
13.2.3 should invoke an optional callback passed to _close
258265
13.3 Testing QueryStream\'s maxRows control
259266
13.3.1 should use oracledb.maxRows for fetching
260-
13.3.2 should default to 100 if oracledb.maxRows is falsey
267+
13.3.2 should default to 100 if oracledb.maxRows is false
261268

262269
14. stream2.js
263-
14.1 Bind by position and return an array
264-
14.2 Bind by name and return an array
265-
14.3 Bind by position and return an object
266-
14.4 Bind by name and return an object
267-
14.5 explicitly set resultSet option to be false
268-
14.6 maxRows option is ignored as expect
269-
14.7 Negative - queryStream() has no parameters
270-
14.8 Negative - give invalid SQL as first parameter
271-
14.9 Negative - give non-query SQL
270+
14.1 meta data event
271+
14.2 Bind by position and return an array
272+
14.3 Bind by name and return an array
273+
14.4 Bind by position and return an object
274+
14.5 Bind by name and return an object
275+
14.6 explicitly setting resultSet option to be false takes no effect
276+
14.7 maxRows option is ignored as expect
277+
14.8 Negative - queryStream() has no parameters
278+
14.9 Negative - give invalid SQL as first parameter
279+
14.10 Negatvie - give non-query SQL
272280

273281
15. resultsetToQueryStream.js
274282
15.1 Testing ResultSet.toQueryStream
@@ -283,17 +291,17 @@ Overview of node-oracledb functional tests
283291
15.2.7 should prevent calling toQueryStream more than once
284292

285293
16. promises.js
286-
16.1 returns a promise from oracledb.getConnection
287-
16.2 returns a promise from oracledb.createPool
288-
16.3 returns a promise from pool.terminate
289-
16.4 returns a promise from pool.getConnection
290-
16.5 returns a promise from connection.release
291-
16.6 returns a promise from connection.execute
292-
16.7 returns a promise from connection.commit
293-
16.8 returns a promise form connection.rollback
294-
16.9 returns a promise from resultSet.close
295-
16.10 returns a promise from resultSet.getRow
296-
16.11 returns a promise from resultSet.getRows
294+
16.1 returns a promise from oracledb.getConnection
295+
16.2 returns a promise from oracledb.createPool
296+
16.3 returns a promise from pool.terminate
297+
16.4 returns a promise from pool.getConnection
298+
16.5 returns a promise from connection.release
299+
16.6 returns a promise from connection.execute
300+
16.7 returns a promise from connection.commit
301+
16.8 returns a promise form connection.rollback
302+
16.9 returns a promise from resultSet.close
303+
16.10 returns a promise from resultSet.getRow
304+
16.11 returns a promise from resultSet.getRows
297305

298306
21. datatypeAssist.js
299307

test/stream1.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ describe('13. stream1.js', function () {
6565
" END; \n" +
6666
" EXECUTE IMMEDIATE (' \n" +
6767
" CREATE TABLE nodb_employees ( \n" +
68-
" employees_id NUMBER, \n" +
69-
" employees_name VARCHAR2(20), \n" +
70-
" employees_history CLOB \n" +
68+
" employee_id NUMBER, \n" +
69+
" employee_name VARCHAR2(20), \n" +
70+
" employee_history CLOB \n" +
7171
" ) \n" +
7272
" '); \n" +
7373
"END; ";
@@ -89,7 +89,7 @@ describe('13. stream1.js', function () {
8989
" FOR i IN 1..217 LOOP \n" +
9090
" x := x + 1; \n" +
9191
" n := 'staff ' || x; \n" +
92-
" INSERT INTO nodb_employees VALUES (x, n, EMPTY_CLOB()) RETURNING employees_history INTO clobData; \n" +
92+
" INSERT INTO nodb_employees VALUES (x, n, EMPTY_CLOB()) RETURNING employee_history INTO clobData; \n" +
9393
" DBMS_LOB.WRITE(clobData, 20, 1, '12345678901234567890'); \n" +
9494
" END LOOP; \n" +
9595
"end; ";
@@ -129,7 +129,7 @@ describe('13. stream1.js', function () {
129129
it('13.1.1 stream results for oracle connection', function (done) {
130130
connection.should.be.ok;
131131

132-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
132+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
133133

134134
stream.on('error', function (error) {
135135
should.fail(error, null, 'Error event should not be triggered');
@@ -151,7 +151,7 @@ describe('13. stream1.js', function () {
151151
it('13.1.2 stream results for oracle connection (outFormat: oracledb.OBJECT)', function (done) {
152152
connection.should.be.ok;
153153

154-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees', {}, {
154+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name', {}, {
155155
outFormat: oracledb.OBJECT
156156
});
157157

@@ -190,7 +190,7 @@ describe('13. stream1.js', function () {
190190
it('13.1.4 no result', function (done) {
191191
connection.should.be.ok;
192192

193-
var stream = connection.queryStream('SELECT * FROM nodb_employees WHERE employees_name = :name', {
193+
var stream = connection.queryStream('SELECT * FROM nodb_employees WHERE employee_name = :name', {
194194
name: 'TEST_NO_RESULT'
195195
});
196196

@@ -213,7 +213,7 @@ describe('13. stream1.js', function () {
213213
it('13.1.5 single row', function (done) {
214214
connection.should.be.ok;
215215

216-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees WHERE employees_name = :name', {
216+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees WHERE employee_name = :name', {
217217
name: 'staff 10'
218218
});
219219

@@ -239,7 +239,7 @@ describe('13. stream1.js', function () {
239239
it('13.1.6 multiple row', function (done) {
240240
connection.should.be.ok;
241241

242-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees WHERE employees_id <= :maxId ORDER BY employees_id', {
242+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees WHERE employee_id <= :maxId ORDER BY employee_id', {
243243
maxId: 10
244244
}, {
245245
outFormat: oracledb.OBJECT
@@ -253,7 +253,7 @@ describe('13. stream1.js', function () {
253253
stream.on('data', function (data) {
254254
should.exist(data);
255255
should.deepEqual(data, {
256-
EMPLOYEES_NAME: 'staff ' + (counter + 1)
256+
EMPLOYEE_NAME: 'staff ' + (counter + 1)
257257
});
258258

259259
counter++;
@@ -269,7 +269,7 @@ describe('13. stream1.js', function () {
269269
it('13.1.7 invalid SQL', function (done) {
270270
connection.should.be.ok;
271271

272-
var stream = connection.queryStream('UPDATE nodb_employees SET employees_name = :name WHERE employees_id :id', {
272+
var stream = connection.queryStream('UPDATE nodb_employees SET employee_name = :name WHERE employee_id = :id', {
273273
id: 10,
274274
name: 'test_update'
275275
}, {
@@ -290,7 +290,7 @@ describe('13. stream1.js', function () {
290290
it('13.1.8 Read CLOBs', function (done) {
291291
connection.should.be.ok;
292292

293-
var stream = connection.queryStream('SELECT employees_name, employees_history FROM nodb_employees where employees_id <= :maxId ORDER BY employees_id', {
293+
var stream = connection.queryStream('SELECT employee_name, employee_history FROM nodb_employees where employee_id <= :maxId ORDER BY employee_id', {
294294
maxId: 10
295295
}, {
296296
outFormat: oracledb.OBJECT
@@ -307,18 +307,18 @@ describe('13. stream1.js', function () {
307307
var rowIndex = counter;
308308

309309
should.exist(data);
310-
should.equal(data.EMPLOYEES_NAME, 'staff ' + (rowIndex + 1));
310+
should.equal(data.EMPLOYEE_NAME, 'staff ' + (rowIndex + 1));
311311

312-
should.exist(data.EMPLOYEES_HISTORY);
313-
should.equal(data.EMPLOYEES_HISTORY.constructor.name, 'Lob');
312+
should.exist(data.EMPLOYEE_HISTORY);
313+
should.equal(data.EMPLOYEE_HISTORY.constructor.name, 'Lob');
314314

315315
var clob = [];
316-
data.EMPLOYEES_HISTORY.setEncoding('utf8');
317-
data.EMPLOYEES_HISTORY.on('data', function (data) {
316+
data.EMPLOYEE_HISTORY.setEncoding('utf8');
317+
data.EMPLOYEE_HISTORY.on('data', function (data) {
318318
clob.push(data);
319319
});
320320

321-
data.EMPLOYEES_HISTORY.on('end', function () {
321+
data.EMPLOYEE_HISTORY.on('end', function () {
322322
clobs[rowIndex] = clob.join('');
323323
should.equal(clobs[rowIndex], '12345678901234567890');
324324

@@ -344,7 +344,7 @@ describe('13. stream1.js', function () {
344344

345345
this.timeout(10000);
346346

347-
var stream = connection.queryStream('SELECT employees_name, employees_history FROM nodb_employees where employees_id <= :maxId ORDER BY employees_id', {
347+
var stream = connection.queryStream('SELECT employee_name, employee_history FROM nodb_employees where employee_id <= :maxId ORDER BY employee_id', {
348348
maxId: 10
349349
}, {
350350
outFormat: oracledb.OBJECT
@@ -362,20 +362,20 @@ describe('13. stream1.js', function () {
362362
var rowIndex = counter;
363363

364364
should.exist(data);
365-
should.equal(data.EMPLOYEES_NAME, 'staff ' + (rowIndex + 1));
365+
should.equal(data.EMPLOYEE_NAME, 'staff ' + (rowIndex + 1));
366366

367-
should.exist(data.EMPLOYEES_HISTORY);
368-
should.equal(data.EMPLOYEES_HISTORY.constructor.name, 'Lob');
367+
should.exist(data.EMPLOYEE_HISTORY);
368+
should.equal(data.EMPLOYEE_HISTORY.constructor.name, 'Lob');
369369

370370
var clob = [];
371-
data.EMPLOYEES_HISTORY.setEncoding('utf8');
371+
data.EMPLOYEE_HISTORY.setEncoding('utf8');
372372

373373
setTimeout(function () {
374-
data.EMPLOYEES_HISTORY.on('data', function (data) {
374+
data.EMPLOYEE_HISTORY.on('data', function (data) {
375375
clob.push(data);
376376
});
377377

378-
data.EMPLOYEES_HISTORY.on('end', function () {
378+
data.EMPLOYEE_HISTORY.on('end', function () {
379379
clobs[rowIndex] = clob.join('');
380380
should.equal(clobs[rowIndex], '12345678901234567890');
381381

@@ -400,15 +400,15 @@ describe('13. stream1.js', function () {
400400
it('13.1.10 meta data', function (done) {
401401
connection.should.be.ok;
402402

403-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees WHERE employees_name = :name', {
403+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees WHERE employee_name = :name', {
404404
name: 'staff 10'
405405
});
406406

407407
var metaDataRead = false;
408408
stream.on('metadata', function (metaData) {
409409
should.deepEqual(metaData, [
410410
{
411-
name: 'EMPLOYEES_NAME'
411+
name: 'EMPLOYEE_NAME'
412412
}
413413
]);
414414
metaDataRead = true;
@@ -434,7 +434,7 @@ describe('13. stream1.js', function () {
434434

435435
connection.should.be.ok;
436436

437-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
437+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
438438

439439
stream.on('error', function (error) {
440440
should.fail(error, null, 'Error event should not be triggered');
@@ -453,7 +453,7 @@ describe('13. stream1.js', function () {
453453

454454
var testDone = 0;
455455
var subTest = function (callback) {
456-
var query = connection.queryStream('SELECT employees_name FROM nodb_employees');
456+
var query = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
457457

458458
query.on('error', function (error) {
459459
should.fail(error, null, 'Error event should not be triggered');
@@ -493,7 +493,7 @@ describe('13. stream1.js', function () {
493493
it('13.2.1 should be able to stop the stream early with _close', function (done) {
494494
connection.should.be.ok;
495495

496-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
496+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
497497

498498
stream.on('data', function () {
499499
stream.pause();
@@ -516,7 +516,7 @@ describe('13. stream1.js', function () {
516516
it('13.2.2 should be able to stop the stream before any data', function (done) {
517517
connection.should.be.ok;
518518

519-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
519+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
520520

521521
stream.on('close', function() {
522522
done();
@@ -541,7 +541,7 @@ describe('13. stream1.js', function () {
541541
it('13.2.3 should invoke an optional callback passed to _close', function (done) {
542542
connection.should.be.ok;
543543

544-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
544+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
545545

546546
stream._close(function() {
547547
done();
@@ -572,7 +572,7 @@ describe('13. stream1.js', function () {
572572

573573
oracledb.maxRows = testMaxRows;
574574

575-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
575+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
576576

577577
stream.on('data', function () {
578578
stream.pause();
@@ -596,7 +596,7 @@ describe('13. stream1.js', function () {
596596
});
597597
});
598598

599-
it('13.3.2 should default to 100 if oracledb.maxRows is falsey', function (done) {
599+
it('13.3.2 should default to 100 if oracledb.maxRows is false', function (done) {
600600
var defaultMaxRows;
601601
var testMaxRows = 0;
602602

@@ -606,7 +606,7 @@ describe('13. stream1.js', function () {
606606

607607
oracledb.maxRows = testMaxRows;
608608

609-
var stream = connection.queryStream('SELECT employees_name FROM nodb_employees');
609+
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
610610

611611
stream.on('data', function () {
612612
stream.pause();

0 commit comments

Comments
 (0)