Skip to content

Using the v4.0.0, when the Object.prototype had been chained a method, the Connection.executeMany goes error with NJS-060 prompt. #1129

@TheNorthMemory

Description

@TheNorthMemory

The behavior is similar to node-modules/urllib#312, the sample code as below:

const data = [
    {"rate_user":"Bob","rate_time":"2019-07-26 19:42:36","item_price":338,"rating":"I like it"},
    {"rate_user":"Alice","rate_time":"2019-07-26 19:42:36","item_price":338,"rating":"I like it too"}
];

const cfg = require('./dbConfig');
const oracledb = require('oracledb');

Object.prototype.noop = () => {}

(async () => {

  const options = {
    autoCommit: true,
    bindDefs: {
      item_price : { type: oracledb.NUMBER },
      rate_time  : { type: oracledb.STRING, maxSize: 32 },
      rate_user  : { type: oracledb.STRING, maxSize: 128 },
      rating     : { type: oracledb.STRING, maxSize: 4000 },
    }
  };

  const sql = `MERGE INTO RATING R USING ( SELECT
      :item_price as itemPrice,
      :rate_time as rateTime,
      :rate_user as rateUser,
      :rating as rating
  FROM DUAL ) T ON (
      R.RATE_TIME     = T.rateTime
      AND R.RATE_USER = T.rateUser
  ) WHEN MATCHED THEN UPDATE SET
      R.ITEM_PRICE = T.itemPrice
      , R.RATING   = T.rating
  WHEN NOT MATCHED THEN INSERT (
      RATE_TIME
      , RATE_USER
      , ITEM_PRICE
      , RATING
  ) VALUES (
      T.rateTime
      , T.rateUser
      , T.itemPrice
      , T.rating
  )`;

  const conn = await oracledb.getConnection(cfg);
  try {
    await conn.executeMany(sql, data, options);
  } catch (e) {
    console.error(e);
  }
  await conn.close();

})();
  1. Is it an error or a hang or a crash?

crashed with this message:Error: NJS-060: type must be specified for bind "noop"

  1. What error(s) you are seeing?
Error: NJS-060: type must be specified for bind "noop"
    at Connection.executeMany (/Users/james/data.git/node_modules/oracledb/lib/connection.js:207:21)
    at /Users/james/data.git/node_modules/oracledb/lib/util.js:180:16
    at new Promise (<anonymous>)
    at Connection.executeMany (/Users/james/data.git/node_modules/oracledb/lib/util.js:168:14)
    at /Users/james/data.git/test/rate.executeMany.test.js:48:18
  1. Run node and show the output of:
Welcome to Node.js v12.6.0.
Type ".help" for more information.
> process.platform
'darwin'
>
> process.version
'v12.6.0'
> process.arch
'x64'
> require('oracledb').versionString
'4.0.0'
>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions