jeremydaly / data-api-client

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

PostgreSQL "RETURNING" not returning values #81

Open QAnders opened 3 years ago

QAnders commented 3 years ago

Running the code like:

  sql = `INSERT INTO unit 
    (unit_name, supplier, deleted, "createdAt", "updatedAt", uuid) 
    VALUES (:unit_name, :supplier, :deleted, :createdAt, :updatedAt, :uuid) 
    RETURNING id`;
  const results = await rdsds.query(sql, dbUnits);

  console.log('Units:', results); // Logs "Units: { updateResults: [] }"

Two lines are inserted but the return is an empty Array... Am I missing something...?

QAnders commented 3 years ago

I ran a test both using the local-data-api Docker container locally and using the Aurora Serverelss in AWS and they both return:

{
    "numberOfRecordsUpdated": 0,
    "records": [
        [
            {
                "stringValue": "123"
            }
        ]
    ]
}

From the INSERT with RETURNING id the Serverless API is returning the data but seems it is lost somewhere along the line...