@@ -398,288 +398,7 @@ describe('58. properties.js', function() {
398
398
399
399
} ) // 58.3
400
400
401
- describe ( '58.4 Lob Class' , function ( ) {
402
-
403
- var connection = null ;
404
- var clobTableName = "oracledb_myclobs" ;
405
- var blobTableName = "oracledb_myblobs" ;
406
- var clob = null ,
407
- blob = null ;
408
- var defaultValues = { } ;
409
-
410
- beforeEach ( 'prepare CLOB/BLOB tables' , function ( done ) {
411
- async . series ( [
412
- function ( cb ) {
413
- oracledb . getConnection ( credential , function ( err , conn ) {
414
- should . not . exist ( err ) ;
415
- connection = conn ;
416
- cb ( ) ;
417
- } ) ;
418
- } ,
419
- function ( cb ) {
420
- assist . createTable ( connection , clobTableName , cb ) ;
421
- } ,
422
- function ( cb ) {
423
- assist . createTable ( connection , blobTableName , cb ) ;
424
- } ,
425
- function insertClobData ( cb ) {
426
-
427
- var sql = "INSERT INTO " + clobTableName +
428
- " VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv" ;
429
- var id = 1 ;
430
- var bindVar = { n : id , lobbv : { type : oracledb . CLOB , dir : oracledb . BIND_OUT } } ;
431
- var inFileName = './test/clobexample.txt' ;
432
-
433
- insertLob ( sql , bindVar , inFileName , cb ) ;
434
- } ,
435
- function insertBlobData ( cb ) {
436
-
437
- var sql = "INSERT INTO " + blobTableName +
438
- " VALUES(:n, EMPTY_BLOB()) RETURNING content INTO :lobbv" ;
439
- var id = 1 ;
440
- var bindVar = { n : id , lobbv : { type : oracledb . BLOB , dir : oracledb . BIND_OUT } } ;
441
- var inFileName = './test/fuzzydinosaur.jpg' ;
442
-
443
- insertLob ( sql , bindVar , inFileName , cb ) ;
444
- } ,
445
- function getClobData ( cb ) {
446
- getLob ( clobTableName , cb ) ;
447
- } ,
448
- function getBlobData ( cb ) {
449
- getLob ( blobTableName , cb ) ;
450
- } ,
451
- function keepOriginalValue ( cb ) {
452
- defaultValues . chunkSize = clob . chunkSize ;
453
- cb ( ) ;
454
- }
455
- ] , done ) ;
456
- } ) // before
457
-
458
- afterEach ( 'drop tables, release connection' , function ( done ) {
459
- async . series ( [
460
- function ( cb ) {
461
- clob . pieceSize = defaultValues . chunkSize ;
462
- blob . pieceSize = defaultValues . chunkSize ;
463
- cb ( ) ;
464
- } ,
465
- function ( cb ) {
466
- dropTable ( clobTableName , cb ) ;
467
- } ,
468
- function ( cb ) {
469
- dropTable ( blobTableName , cb ) ;
470
- } ,
471
- function ( cb ) {
472
- connection . release ( function ( err ) {
473
- should . not . exist ( err ) ;
474
- cb ( ) ;
475
- } ) ;
476
- }
477
- ] , done ) ;
478
- } ) // after
479
-
480
-
481
- it ( '58.4.1 chunkSize (read-only)' , function ( ) {
482
- var t1 = clob . chunkSize ,
483
- t2 = blob . chunkSize ;
484
-
485
- t1 . should . be . a . Number ;
486
- t2 . should . be . a . Number ;
487
- t1 . should . eql ( defaultValues . chunkSize ) ;
488
- t1 . should . eql ( t2 ) ;
489
-
490
- try {
491
- clob . chunkSize = t1 + 1 ;
492
- } catch ( err ) {
493
- should . exist ( err ) ;
494
- // console.log(err.message);
495
- // Cannot assign to read only property 'chunkSize' of #<Lob>
496
- }
497
-
498
- try {
499
- blob . chunkSize = t2 + 1 ;
500
- } catch ( err ) {
501
- should . exist ( err ) ;
502
- // console.log(err.message);
503
- // Cannot assign to read only property 'chunkSize' of #<Lob>
504
- }
505
- } ) // 58.4.1
506
-
507
- it ( '58.4.2 length (read-only)' , function ( ) {
508
- var t1 = clob . length ,
509
- t2 = blob . length ;
510
-
511
- t1 . should . be . a . Number ;
512
- t2 . should . be . a . Number ;
513
-
514
- t1 . should . not . eql ( t2 ) ;
515
-
516
- try {
517
- clob . length = t1 + 1 ;
518
- } catch ( err ) {
519
- should . exist ( err ) ;
520
- //console.log(err.message);
521
- // Cannot set property length of #<Lob> which has only a getter
522
- }
523
-
524
- try {
525
- blob . length = t2 + 1 ;
526
- } catch ( err ) {
527
- should . exist ( err ) ;
528
- //console.log(err.message);
529
- // Cannot set property length of #<Lob> which has only a getter
530
- }
531
-
532
- } )
533
-
534
- it ( '58.4.3 pieceSize - default value is chunkSize' , function ( ) {
535
- var t1 = clob . pieceSize ,
536
- t2 = blob . pieceSize ;
537
-
538
- t1 . should . eql ( defaultValues . chunkSize ) ;
539
- t2 . should . eql ( defaultValues . chunkSize ) ;
540
- } )
541
-
542
- it ( '58.4.4 pieceSize - can be increased' , function ( ) {
543
- var defaultChunkSize = defaultValues . chunkSize ;
544
- var incresedVal = defaultChunkSize * 5 ;
545
-
546
- clob . pieceSize *= 5 ;
547
- blob . pieceSize *= 5 ;
548
- ( clob . pieceSize ) . should . eql ( incresedVal ) ;
549
- ( blob . pieceSize ) . should . eql ( incresedVal ) ;
550
- } )
551
-
552
- it ( '58.4.5 pieceSize - can be decreased' , function ( ) {
553
- var defaultChunkSize = defaultValues . chunkSize ;
554
-
555
- defaultChunkSize . should . greaterThan ( 500 ) ;
556
- var decreaseVal = defaultChunkSize - 500 ;
557
-
558
- clob . pieceSize -= 500 ;
559
- blob . pieceSize -= 500 ;
560
- ( clob . pieceSize ) . should . eql ( decreaseVal ) ;
561
- ( blob . pieceSize ) . should . eql ( decreaseVal ) ;
562
- } )
563
-
564
- it ( '58.4.6 pieceSize - can be zero' , function ( ) {
565
- clob . pieceSize = 0 ;
566
- blob . pieceSize = 0 ;
567
-
568
- ( clob . pieceSize ) . should . eql ( 0 ) ;
569
- ( blob . pieceSize ) . should . eql ( 0 ) ;
570
- } )
571
-
572
- it ( '58.4.6 pieceSize - cannot be less than zero' , function ( ) {
573
- try {
574
- clob . pieceSize = - 100 ;
575
- } catch ( err ) {
576
- should . exist ( err ) ;
577
- ( err . message ) . should . startWith ( 'NJS-004' ) ;
578
- // NJS-004: invalid value for property pieceSize
579
- }
580
-
581
- try {
582
- blob . pieceSize = - 100 ;
583
- } catch ( err ) {
584
- should . exist ( err ) ;
585
- ( err . message ) . should . startWith ( 'NJS-004' ) ;
586
- // NJS-004: invalid value for property pieceSize
587
- }
588
- } )
589
-
590
- it ( '58.4.7 type (read-only)' , function ( ) {
591
- var t1 = clob . type ,
592
- t2 = blob . type ;
593
-
594
- t1 . should . eql ( oracledb . CLOB ) ;
595
- t2 . should . eql ( oracledb . BLOB ) ;
596
-
597
- try {
598
- clob . type = t2 ;
599
- } catch ( err ) {
600
- should . exist ( err ) ;
601
- // console.log(err);
602
- // [TypeError: Cannot set property type of #<Lob> which has only a getter]
603
- }
604
-
605
- try {
606
- blob . type = t1 ;
607
- } catch ( err ) {
608
- should . exist ( err ) ;
609
- // console.log(err);
610
- // [TypeError: Cannot set property type of #<Lob> which has only a getter]
611
- }
612
- } )
613
-
614
- function getLob ( tableName , cb )
615
- {
616
- connection . execute (
617
- "SELECT content FROM " + tableName + " WHERE num = : id" ,
618
- { id : 1 } ,
619
- function ( err , result ) {
620
- should . not . exist ( err ) ;
621
- var lob = result . rows [ 0 ] [ 0 ] ;
622
- should . exist ( lob ) ;
623
-
624
- if ( tableName == clobTableName ) {
625
- clob = lob ;
626
- // console.log("Get clob data");
627
- } else if ( tableName == blobTableName ) {
628
- blob = lob ;
629
- // console.log("Get blob data");
630
- } else {
631
- console . log ( "passing wrong table name." ) ;
632
- }
633
-
634
- cb ( ) ;
635
- }
636
- ) ;
637
- }
638
-
639
- function dropTable ( tableName , cb )
640
- {
641
- connection . execute (
642
- "DROP TABLE " + tableName ,
643
- function ( err ) {
644
- should . not . exist ( err ) ;
645
- cb ( ) ;
646
- }
647
- ) ;
648
- }
649
-
650
- function insertLob ( sql , bindVar , inFileName , cb )
651
- {
652
- connection . execute (
653
- sql ,
654
- bindVar ,
655
- function ( err , result ) {
656
- should . not . exist ( err ) ;
657
- var lob = result . outBinds . lobbv [ 0 ] ;
658
- var inStream = fs . createReadStream ( inFileName ) ;
659
-
660
- inStream . on ( 'end' , function ( ) {
661
- connection . commit ( function ( err ) {
662
- should . not . exist ( err ) ;
663
- cb ( ) ;
664
- } ) ;
665
- } ) ;
666
-
667
- inStream . on ( 'error' , function ( err ) {
668
- should . not . exist ( err ) ;
669
- } ) ;
670
-
671
- lob . on ( 'error' , function ( err ) {
672
- should . not . exist ( err ) ;
673
- } ) ;
674
-
675
- inStream . pipe ( lob ) ;
676
- }
677
- ) ;
678
- }
679
-
680
- } ) // 58.4
681
-
682
- describe ( '58.5 ResultSet Class' , function ( ) {
401
+ describe ( '58.4 ResultSet Class' , function ( ) {
683
402
684
403
var tableName = "oracledb_number" ;
685
404
var numbers = assist . data . numbers ;
@@ -727,7 +446,7 @@ describe('58. properties.js', function() {
727
446
) ;
728
447
} )
729
448
730
- it ( '58.5 .1 metaData (read-only)' , function ( ) {
449
+ it ( '58.4 .1 metaData (read-only)' , function ( ) {
731
450
should . exist ( resultSet . metaData ) ;
732
451
var t = resultSet . metaData ;
733
452
t . should . eql ( [ { name : 'NUM' } , { name : 'CONTENT' } ] ) ;
0 commit comments