Skip to Content
Sep 03, 2020 at 02:18 PM

CAP (Node.js) error when running INSERT AS SELECT queries


I don't know where else to submit this. I'm trying to run the following query with `@sap/cds 4.1.9`

INSERT.into(MyTable).columns('column1', 'column2').as(SELECT([
	{ val: `'${now.toISOString()}'`, as: "createdAt"},
	{ val: `'anonymous'`, as: "createdBy"},
	{ val: `'${now.toISOString()}'`, as: "modifiedAt"},
	{ val: `'anonymous'`, as: "modifiedBy"}

which results in the following error:

Exception has occurred: TypeError: Cannot convert undefined or null to object
  at Function.keys (<anonymous>)
    at checkIntegrityUtil (/home/node/app/node_modules/@sap/cds-runtime/lib/cds-services/services/utils/handlerUtils.js:207:14)
    at _performCheck (/home/node/app/node_modules/@sap/cds-runtime/lib/db/generic/integrity.js:71:9)

The code fails because is undefined here.

This used to work fine with `@sap/cds 3.x.x`