jeremydaly / data-api-client

A "DocumentClient" for the Amazon Aurora Serverless Data API
MIT License
444 stars 63 forks source link

Batch Insert fail with 'Cannot find parameter' error if there are some records with null fields #87

Closed nickygb closed 3 years ago

nickygb commented 3 years ago

If I have a table table1 with the column my_field and I try to insert records in batch wiith null values I get the following error: Cannot find parameter: my_field.

If I insert records with not null values the batch insert works properly.

Example:

const parameters = [
  [
    {
      my_field: null,
    },
  ],
  [
    {
       my_field: 1
    },
  ],
];
const sql = `INSERT INTO table1 (my_field) VALUES (:my_field)`;
await client.query(sql, parameters);
nickygb commented 3 years ago

Sorry I have realized that the error is not related with this library.I am using https://github.com/koxudaxi/local-data-api in order to connect to a local endpoint and the problem was that I had have an old version of it with this bug. I have updated it and now the error has disappear.