oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.24k stars 1.07k forks source link

for .. in loop for Array is causing errors when Array.prototype is extended #1653

Closed molda closed 2 months ago

molda commented 3 months ago

On this line https://github.com/oracle/node-oracledb/blob/afb9f696ca7dbdd72150ba5efdc94f3ebffb4133/lib/thin/sqlnet/ezConnectResolver.js#L223 the for...in loop is used which causes an error when Array.prototype is extended since it iterates over the added methods.

Changing the for...in to for...of fixes the issue.

The framework i use Total.js framework v4 is extending the Array prototype by many useful methods.

Example without Total.js:

% node
Welcome to Node.js v20.10.0.
Type ".help" for more information.
> for (const a in [1]) console.log(a)
1

Example with Total.js:

Welcome to Node.js v20.10.0.
Type ".help" for more information.
> require('total4')
> for (const a in [1]) console.log(a)
0
take
first
toObject
last
quicksort
trim
skip
findAll
findValue
findItem
remove
wait
async
random
limit
sharadraju commented 3 months ago

Thanks @molda. We will fix it in the next release after looking at how the for loop has been used.

Were you using the Total.js framework with our previous releases?

molda commented 3 months ago

Thanks @sharadraju for the quick answer. No i never used oracledb before.

sharadraju commented 2 months ago

This has been fixed in the 6.5 release. @molda Please verify.

molda commented 2 months ago

Thank you @sharadraju I'll test it when i have time and report back if needed.