data-api-client icon indicating copy to clipboard operation
data-api-client copied to clipboard

PostgreSQL "RETURNING" not returning values

Open QAnders opened this issue 3 years ago • 1 comments

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 avatar Jan 27 '21 10:01 QAnders

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...

QAnders avatar Jan 28 '21 09:01 QAnders