sapmentors / cap-community

SAP CAP Community
MIT License
97 stars 26 forks source link

Deep insert with only child data not possible in combination with jest/supertest and cds 3.21.3 #39

Open bvmeggelen opened 4 years ago

bvmeggelen commented 4 years ago

We're using Jest and supertest to unit test our cds-based endpoints. While upgrading from @sap/cds 3.18.x to 3.21.3 our tests started to break on a deep insert.

I've been able to reproduce the issue in an isolated scenario here: https://github.com/bvmeggelen/cds-jest-supertest-use-case-1.

Basically, when trying to deep insert without setting an additional field on the same level, the test breaks. However, using Postman and the same example data, it works just fine.

The following example JSON breaks the test: { "child": [ { "key": "value" } ] }

However, when using this it works as expected: { "some-field": "some-value", "child": [ { "key": "value" } ] }

Please see the referred git repository for a full reproducible example.

vobu commented 4 years ago

interesting issue since your abstract key

abstract entity mrid {
    key mRID: UUID;
}

is essentially a dup of @sap/cds/common/cuid

abstract entity cuid {
  key ID : UUID; //> automatically filled in
}

so I'd expect it to work the same way. Let's see what the CAP corez have to say :)