27
27
* clobinsert1.js, clobstream1.js and clobstream2.js
28
28
* Firstly, reads text from clobexample.txt and INSERTs it into a CLOB column.
29
29
* Secondly, SELECTs a CLOB and pipes it to a file, clobstreamout.txt
30
- * Thirdly, SELECTs the CLOB and compares it with the content in clobexample.txt
30
+ * Thirdly, SELECTs the CLOB and compares it with the content in clobexample.txt.
31
+ * Fourthly, query the CLOB with Object outFormat.
31
32
*
32
33
* NUMBERING RULE
33
34
* Test numbers follow this numbering rule:
@@ -49,7 +50,7 @@ var inFileName = './test/clobexample.txt'; // the file with text to be inserted
49
50
var outFileName = './test/clobstreamout.txt' ;
50
51
51
52
describe ( '40. dataTypeClob.js' , function ( ) {
52
- this . timeout ( 10000 ) ;
53
+ this . timeout ( 15000 ) ;
53
54
54
55
if ( dbConfig . externalAuth ) {
55
56
var credential = { externalAuth : true , connectString : dbConfig . connectString } ;
@@ -212,6 +213,43 @@ describe('40. dataTypeClob.js', function() {
212
213
} ) ;
213
214
} ) ;
214
215
216
+ lob . on ( 'error' , function ( err ) {
217
+ should . not . exist ( err , "lob.on 'error' event" ) ;
218
+ } ) ;
219
+ }
220
+ ) ;
221
+ } ,
222
+ function objectOutFormat ( callback ) {
223
+ var lobEndEventFired = false ;
224
+ var lobDataEventFired = false ;
225
+ setTimeout ( function ( ) {
226
+ lobDataEventFired . should . equal ( true , "lob does not call 'data' event!" ) ;
227
+ lobEndEventFired . should . equal ( true , "lob does not call 'end' event!" ) ;
228
+ callback ( ) ;
229
+ } , 2000 ) ;
230
+
231
+ connection . execute (
232
+ "SELECT content FROM oracledb_myclobs WHERE num = :n" ,
233
+ { n : 1 } ,
234
+ { outFormat : oracledb . OBJECT } ,
235
+ function ( err , result ) {
236
+ should . not . exist ( err ) ;
237
+
238
+ var clob = '' ;
239
+ var row = result . rows [ 0 ] ;
240
+ var lob = row [ 'CONTENT' ] ;
241
+
242
+ lob . setEncoding ( 'utf8' ) ;
243
+
244
+ lob . on ( 'data' , function ( chunk ) {
245
+ lobDataEventFired = true ;
246
+ clob += chunk ;
247
+ } ) ;
248
+
249
+ lob . on ( 'end' , function ( ) {
250
+ lobEndEventFired = true ;
251
+ } ) ;
252
+
215
253
lob . on ( 'error' , function ( err ) {
216
254
should . not . exist ( err , "lob.on 'error' event" ) ;
217
255
} ) ;
0 commit comments