@@ -221,6 +221,46 @@ describe('40. dataTypeClob.js', function() {
221
221
] , done ) ; // async
222
222
223
223
} ) // 40.1.1
224
+
225
+ it ( '40.1.2 catches Error event correctly' , function ( done ) {
226
+ var lobErrorEvent = false ;
227
+ setTimeout ( function ( ) {
228
+ lobErrorEvent . should . equal ( true , "LOB should catch the 'error' event!" ) ;
229
+ done ( ) ;
230
+ } , 1000 ) ;
231
+
232
+ connection . execute (
233
+ "INSERT INTO oracledb_myclobs (num, content) VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv" ,
234
+ { n : 2 , lobbv : { type : oracledb . CLOB , dir : oracledb . BIND_OUT } } ,
235
+ { autoCommit : true } ,
236
+ function ( err , result ) {
237
+ should . not . exist ( err ) ;
238
+ ( result . rowsAffected ) . should . be . exactly ( 1 ) ;
239
+ ( result . outBinds . lobbv . length ) . should . be . exactly ( 1 ) ;
240
+
241
+ var inStream = fs . createReadStream ( inFileName ) ;
242
+ var lob = result . outBinds . lobbv [ 0 ] ;
243
+
244
+ lob . on ( 'error' , function ( err ) {
245
+ should . exist ( err , "lob.on 'error' event" ) ;
246
+ ( err . message ) . should . startWith ( 'ORA-22990' ) ;
247
+ // ORA-22990: LOB locators cannot span transactions
248
+ lobErrorEvent = true ;
249
+ } ) ;
250
+
251
+ inStream . on ( 'error' , function ( err ) {
252
+ should . not . exist ( err , "inStream.on 'error' event" ) ;
253
+ } ) ;
254
+
255
+ inStream . on ( 'end' , function ( ) {
256
+ connection . commit ( function ( err ) {
257
+ should . not . exist ( err ) ;
258
+ } ) ;
259
+ } ) ;
260
+ inStream . pipe ( lob ) ;
261
+ }
262
+ ) ;
263
+ } )
224
264
} ) // 40.1
225
265
226
266
describe ( '40.2 stores null value correctly' , function ( ) {
0 commit comments