Fixed a regression when enumerable properties were added to Object.prototype

This commit is contained in:
Christopher Jones 2019-08-14 21:48:06 +10:00
parent bfa79ae75f
commit b08bd02b23
5 changed files with 33 additions and 7 deletions

View File

@ -4,6 +4,10 @@
**This release is under development**
- Fixed a regression when enumerable properties were added to
`Object.prototype`.
([#1129](https://github.com/oracle/node-oracledb/issues/1129)).
- Fixed a regression with missing `metaData` from `connection.getStatementInfo()`
- Fixed passing DbObjects and JavaScript objects as the `payload` attribute for

View File

@ -452,7 +452,8 @@ bool njsBaton_getFetchInfoFromArg(njsBaton *baton, napi_env env,
return true;
// extract the property names from the object
NJS_CHECK_NAPI(env, napi_get_property_names(env, value, &keys))
if (!njsUtils_getOwnPropertyNames(env, value, &keys))
return false;
// allocate space for the fetchInfo based on the number of keys
NJS_CHECK_NAPI(env, napi_get_array_length(env, keys, &numElements))

View File

@ -1994,9 +1994,8 @@ static bool njsConnection_processExecuteBinds(njsBaton *baton,
// if binding by name, get the list of bind names
bindNames = NULL;
if (!isArray) {
NJS_CHECK_NAPI(env, napi_get_property_names(env, binds, &bindNames))
}
if (!isArray && !njsUtils_getOwnPropertyNames(env, binds, &bindNames))
return false;
// initialize variables; if there are no variables, nothing further to do!
baton->bindArraySize = 1;
@ -2069,9 +2068,8 @@ static bool njsConnection_processExecuteManyBinds(njsBaton *baton,
// get the list of bind names, if binding by name
bindNames = NULL;
if (!bindByPos) {
NJS_CHECK_NAPI(env, napi_get_property_names(env, bindDefs, &bindNames))
}
if (!bindByPos && !njsUtils_getOwnPropertyNames(env, bindDefs, &bindNames))
return false;
// initialize variables; if there are no variables, nothing further to do!
if (!njsConnection_initBindVars(baton, env, bindDefs, bindNames))

View File

@ -943,6 +943,8 @@ bool njsUtils_getError(napi_env env, dpiErrorInfo *errorInfo,
bool njsUtils_getIntArg(napi_env env, napi_value *args, int index,
int32_t *result);
napi_value njsUtils_getNull(napi_env env);
bool njsUtils_getOwnPropertyNames(napi_env env, napi_value value,
napi_value *names);
bool njsUtils_getStringArg(napi_env env, napi_value *args, int index,
char **result, size_t *resultLength);
bool njsUtils_getStringFromArg(napi_env env, napi_value *args,

View File

@ -508,6 +508,27 @@ napi_value njsUtils_getNull(napi_env env)
}
//-----------------------------------------------------------------------------
// njsUtils_getOwnPropertyNames()
// Returns an array of property names owned specifically by the given object.
//-----------------------------------------------------------------------------
bool njsUtils_getOwnPropertyNames(napi_env env, napi_value value,
napi_value *names)
{
napi_value global, globalObject, method;
NJS_CHECK_NAPI(env, napi_get_global(env, &global))
NJS_CHECK_NAPI(env, napi_get_named_property(env, global, "Object",
&globalObject))
NJS_CHECK_NAPI(env, napi_get_named_property(env, globalObject,
"getOwnPropertyNames", &method))
NJS_CHECK_NAPI(env, napi_call_function(env, globalObject, method, 1,
&value, names))
return true;
}
//-----------------------------------------------------------------------------
// njsUtils_getStringArg()
// Gets a string from the specified parameter. If the value is not a string,