-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue retrieving BLOB from database (oracle) - iLob attribute undefined #3467
Comments
What version of Oracle driver (nodejs dependency) are you using? There was a major update lately that knex is not compatible with yet. |
We are now using the 4.0.1 version of oracledb. That's true there was no issue with the old 1.13.1 version of oracledb and the 0.13.0 version of knex. |
I think it is #3396 |
@matthieu-1989 Could you please try with 0.20.0? |
Fix doesn't seem to work with BLOB data type. Checked with knex v0.20.1: CLOB data can be retrieved successfully but knex hangs when retrieving data from a BLOB column. Debugging shows the execution waiting forever at line #353 when trying to concatenate two buffers: I have oracledb v4.0.1 installed with 'Oracle Database 19c Enterprise Edition Release 19.0.0.0.0'. And I have node running on mac. |
I'm seeing the same results as @lpillai
investigating 🤔 |
Modifying the knex/lib/dialects/oracledb/index.js Line 342 in f4099af
function readStream(stream, type) {
return new Promise((resolve, reject) => {
let data;
if (type === 'string') {
data = '';
} else {
data = Buffer.alloc(0); // allocate to empty Buffer when not string
}
stream.on('error', function(err) {
reject(err);
});
stream.on('data', function(chunk) {
if (type === 'string') {
data += chunk;
} else {
// handle non-string chunking
const blobLength = data.length + chunk.length;
data = Buffer.concat([data, chunk], blobLength);
}
});
stream.on('end', function() {
resolve(data);
});
});
} resolves the issue. This essentially splits the code to handle streams of type I'll try and submit a PR when possible. |
@robmcguinness Is is the same as https://github.com/knex/knex/pull/3545/files? If you can confirm that fix is sufficient, I can release a new version with fix. |
@kibertoad it does appear to be the same and more concisely written 😄 |
Released in 0.20.3 |
@robmcguinness Please let me know if new version fixes the issue for you! |
the fix appears to work. much appreciated @kibertoad! 🙏 |
Knex version: 0.19.5
Objection version: 1.6.0
Database + version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
OS: Windows 10 Professional
@atiertant
While retrieving data from database, if at least one of the result column type is BLOB, the query fails.
Error message:
Cannot read property 'type' of undefined",
"stack":"TypeError: Cannot read property 'type' of undefined
at readStream (my_node_modules\knex\lib\dialects\oracledb\index.js:355:19
Checking "knex\lib\dialects\oracledb\index.js" code. The "stream" input attribute passed to the readStream function (line 355) doesn't have a "iLob" attribute.
Regards,
Matthieu
The text was updated successfully, but these errors were encountered: