Closed DinoWinter closed 1 month ago
Hi @DinoWinter,
I don't think default null
makes much sense. If you omit that the default is anyway null
on the db.
Could you double check that?
Hi @johannes-vogel,
you're right that the default null
is not needed in the CDS table definition. It changes nothing in the table created on the HANA-DB.
If I remove the default null
from the CDS it works as expected. But I have old projects where the default null
is explicitly written in the CDS files and it works without problems now. So I have to check all CDS files if i move to the new cap-js/hana because it does not handle it as expected/before?
Ok, its tedious but seems to be necessary :)
Best regards,
Dino
Insert a row in a table with columns with default null leads to current timestamps in these columns.
using { managed } from '@sap/cds/common';
entity Test : managed { key id : UUID; description : String(255); anotherText : String(255) default null; loggedAt : Timestamp default null;
};
{ "description": "a new description" }
HTTP/1.1 201 Created X-Powered-By: Express X-Correlation-ID: 7f46ab8b-41b2-4e92-b392-7be6e985075b OData-Version: 4.0 location: Test(87bb7c82-c059-4ebe-aa9a-62becc5cc04e) Content-Type: application/json; charset=utf-8 Content-Length: 328 Date: Mon, 05 Aug 2024 14:33:24 GMT Connection: close
{ "@odata.context": "$metadata#Test/$entity", "anotherText": "2024-08-05T14:33:24.882Z", "createdAt": "2024-08-05T14:33:24.882Z", "createdBy": "privileged", "description": "a new description", "id": "87bb7c82-c059-4ebe-aa9a-62becc5cc04e", "loggedAt": "2024-08-05T14:33:24.882Z", "modifiedAt": "2024-08-05T14:33:24.882Z", "modifiedBy": "privileged" }
If the colunns has a default value of null then d.val is null and the date is set as the value for the column.
Details about your project