@@ -167,7 +167,6 @@ describe('41. dataTypeBlob.js', function() {
167
167
const plsql = testsUtil . sqlCreateTable ( TABLE , createTable ) ;
168
168
169
169
before ( 'create table' , async function ( ) {
170
- oracledb . fetchAsBuffer = [ oracledb . BLOB ] ;
171
170
if ( testsUtil . getClientVersion ( ) >= 2100000000 &&
172
171
connection . oracleServerVersion >= 2100000000 ) {
173
172
isRunnable = true ;
@@ -177,11 +176,13 @@ describe('41. dataTypeBlob.js', function() {
177
176
this . skip ( ) ;
178
177
}
179
178
179
+ // Allows automatically converting OSON formatted columns to JSON objects.
180
+ oracledb . future . oldJsonColumnAsObj = true ;
180
181
await connection . execute ( plsql ) ;
181
182
} ) ;
182
183
183
184
after ( async function ( ) {
184
- oracledb . fetchAsBuffer = [ ] ;
185
+ oracledb . future . oldJsonColumnAsObj = false ;
185
186
await connection . execute ( testsUtil . sqlDropTable ( TABLE ) ) ;
186
187
} ) ;
187
188
@@ -203,25 +204,30 @@ describe('41. dataTypeBlob.js', function() {
203
204
values (1, :1, :2) ` ,
204
205
[ byteBuf , byteBuf ] ) ;
205
206
result = await connection . execute ( `select OSONCOL from ${ TABLE } ` ) ;
206
- let generatedObj = connection . decodeOSON ( result . rows [ 0 ] [ 0 ] ) ;
207
- assert . deepStrictEqual ( expectedObj1 , generatedObj ) ;
207
+ assert . deepStrictEqual ( expectedObj1 , result . rows [ 0 ] [ 0 ] ) ;
208
208
209
209
// Generate OSON bytes and insert these bytes and verify with decode.
210
210
const osonBytes = connection . encodeOSON ( expectedObj2 ) ;
211
211
result = await connection . execute ( `insert into ${ TABLE } (IntCol, OsonCol, blobCol)
212
212
values (2, :1, :2) ` ,
213
213
[ osonBytes , byteBuf ] ) ;
214
214
result = await connection . execute ( `select OSONCOL from ${ TABLE } where IntCol = 2` ) ;
215
- generatedObj = connection . decodeOSON ( result . rows [ 0 ] [ 0 ] ) ;
216
- assert . deepStrictEqual ( expectedObj2 , generatedObj ) ;
215
+ assert . deepStrictEqual ( expectedObj2 , result . rows [ 0 ] [ 0 ] ) ;
217
216
218
217
// Verify vector inside OSON image for 23.4 server onwards.
219
218
if ( connection . oracleServerVersion >= 2304000000 ) {
220
219
result = await connection . execute ( `insert into ${ TABLE } (IntCol, OsonCol, blobCol)
221
220
values (3, :1, :2) ` ,
222
221
[ connection . encodeOSON ( expectedObj3 ) , byteBuf ] ) ;
223
222
result = await connection . execute ( `select OSONCOL from ${ TABLE } where IntCol = 3` ) ;
224
- generatedObj = connection . decodeOSON ( result . rows [ 0 ] [ 0 ] ) ;
223
+ assert . deepStrictEqual ( expectedObj3 , result . rows [ 0 ] [ 0 ] ) ;
224
+
225
+ // Verify LOB is returned by default (oracledb.future.oldJsonColumnAsObj = false).
226
+ // We need to explicitly use decodeOSON to convert the LOB data into JSON object.
227
+ oracledb . future . oldJsonColumnAsObj = false ;
228
+ result = await connection . execute ( `select OSONCOL from ${ TABLE } where IntCol = 3` ) ;
229
+ const lob = result . rows [ 0 ] [ 0 ] ;
230
+ const generatedObj = connection . decodeOSON ( await lob . getData ( ) ) ;
225
231
assert . deepStrictEqual ( expectedObj3 , generatedObj ) ;
226
232
}
227
233
0 commit comments