-
Notifications
You must be signed in to change notification settings - Fork 1.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
Prevent mutation of arguments #1528
Comments
querystream does not return promise last time I checked, prob more like this const rowStream = connection.queryStream<T>(query, params, DEFAULT_OPTIONS);
rowStream.on("data", function (rowData) {
//do something here with row data
}) Also need event for end/error etc like docs says |
@VegarRingdalAibel |
read it a bit too quick |
I noticed this recently while working on the new enhancements for version 6 and took the time to eliminate the mutation there. So this will be corrected in version 6 anyway. I'll let @cjbj decide whether this needs to be addressed sooner -- but considering you are the first to notice this in the entire lifetime of the driver I suspect it will wait until version 6 is released! |
Regardless of the queryStream problem, you might consider replacing your for-await-yield loop with the third example of chapter 17.1.2. |
@sosoba thanks, can you please elaborate why the code above might not work well? I was hoping that using Also I see in those docs that in v. 5.5.0 the result sets are async iterable, but the TS definitions haven't been updated yet, but I guess those are maintained by someone else. |
|
@cjbj no that's the only issue I've had so the |
Hi @diegomansua, now that version 6.0 is out, Can you check if the mutation of arguments is happening for your code with the latest version? Check out #1552 for node-oracledb 6.0 release details. |
@sharadraju Tested right now and works great, thanks! Also the thin mode is really nice. |
Thanks a lot, @diegomansua. Closing this issue now. |
I spent a couple of hours yesterday debugging an issue caused by the mutation of arguments, specifically the
options
one, here: https://github.com/oracle/node-oracledb/blob/v5.5.0/lib/connection.js#L587My code looked like this:
So if I called my
runQueryGenerator
util function and then therunQuery
one, the latter would fail asrows
would be undefined and there would be aresultSet
field in the result instead, as the call toconnection.queryStream
is mutating myDEFAULT_OPTIONS
const and settingresultSet = true
.This causes an issue which is hard to debug and that's easily preventable. The
queryStream
function can simply use the spread operator orObject.assign
or whatever to create its own copy of theoptions
argument.There's also linting rules to spot this. https://eslint.org/docs/latest/rules/no-param-reassign
I'm using 5.3.0 but the issue is present in the latest 5.5.0.
The text was updated successfully, but these errors were encountered: