Any way to override apparent default behaviour where carraige return and line feed are substituted in string results with /r, /n?
Same behaviour can be seen for varchar2 and clob columns...which is not surprising since I'm saying oracledb.fetchAsString = [oracledb.CLOB];
test case:
create table otn_clob (id number generated always as identity,
clob_column clob);
insert into otn_clob (clob_column)
values('this sentance has a
new line in it');
const oracledb = require('oracledb');
oracledb.createPool(
{
poolAlias: 'defaultPoo'l,
user: username,
password: password,
connectString: connstring
})
.then((pool) => {
pool.getConnection()
.then((connection) => {
oracledb.fetchAsString = [oracledb.CLOB];
connection.execute('select id, clob_column from otn_clob', // sql
{ }, // binds
{ }) // options
.then((result) => {
connection.close()
.then(() => { console.log(result.rows); });
})
.catch((queryErr) => {
console.error('create pool: ' + queryErr.message);
connection.close();
});
})
.catch((connectionErr) => {
console.error('create pool: ' + connectionErr.message);
});
})
.catch((poolErr) => {
console.error('create pool: ' + poolErr.message);
});
output:
[ [ 1, 'this sentance has a\nnew line in it' ] ]
I can understand why oracledb does this - control characters not allowed in JSON.
I have some code that takes these results and converts them to csv using json2csv. The CSV is generated with \n.
Question is: is there a way to override this default behaviour or do I need to parse the json before passing it to the csv converter? ...