sapmentors / cap-community

SAP CAP Community
MIT License
97 stars 26 forks source link

CDS (3 and 4) - a field of type timestamp is stored wrong when using HANA #96

Open the-docta opened 4 years ago

the-docta commented 4 years ago

(filed as 561141 / 2020)

I have a CAP data model, where I have a field BeginDate of type DateTime. When the field is stored in HANA (via CDS - currently version 4), the field is stored shifted by tqo hours (which exactly corresponds to the used timezone)

I debugged the case through to the place where cds-runtime is calling hana-client. The data is passed correctly. the hana-client stores the data in the HANA DB and ignores the timezone when doing that.

In the screenshot, the SQL Statement is shown, that is passed to hana client: UPDATE ... SET BeginDate = "2020-08-22T14:02:00.000+02:00"

in the HANA table, the begin date is then stored as 2020-08-22 14:02:00 UTC. which is wrong. It should be storing 12:02:00 UTC.

cds version: @sap/audit-logging: 3.1.1 @sap/cds: 4.1.7 @sap/cds-compiler: 1.35.0 @sap/cds-dk: 2.0.8 @sap/cds-foss: 2.0.0 @sap/cds-mtx: 1.0.17 @sap/cds-reflect: 2.12.2 @sap/cds-runtime: 2.1.7 @sap/hana-client: 2.5.105 @sap/hdi-deploy: 3.11.11 @sap/instance-manager: 2.2.0 @sap/xsenv: 3.0.0 @sap/xssec: 3.0.9 Node.js: v12.12.0

image