Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Cannot read properties of undefined (reading 'split')" #122

Open
D027152 opened this issue Sep 30, 2024 · 1 comment
Open

Error "Cannot read properties of undefined (reading 'split')" #122

D027152 opened this issue Sep 30, 2024 · 1 comment
Assignees
Labels
author action Need the actions taken by an author

Comments

@D027152
Copy link

D027152 commented Sep 30, 2024

Hello colleagues

We upgrade to"@sap/cds": "8.x.x" from "@sap/cds": "7.x.x", and face the following problem.

We have an entity that has a property that is typed as DateTime or Timestamp (in the cds model).
We insert a instance into the entity with INSERT.into ...
In javascript / typescript, the property is of type Date (not: string).

Before the upgrade this worked.
After the upgrade we get in node_modules/@cap-js/change-tracking/lib/change-log.js:177:44 the error
"Cannot read properties of undefined (reading 'split')" See also the screenshot from my local environment:

image

When we instead do the INSERT statement with the property being a string instead of Date, we don't get this error.

The CAP runtime seems to accept the type Date. Therefore, our expectation is that also change tracking should accept Date.

To reconstruct:

  • repo https://github.tools.sap/erp4sme/crypto-for-business
  • branch new_cds
  • npm ci
  • run unit test "01. Add an entry to the BusinessPartners entity -> this should be selected properly" in file lib/masterData/businessPartners/DbBusinessPartnerRepository.ts; this results in the above-mentioned error

Can you please check and advise.

Thank you and best regards,
Stefan

We use CAP with NodeJs.

@Sv7enNowitzki
Copy link
Collaborator

Hi @D027152 ,

I have submitted a PR to address the error you mentioned in the issue.

However, I need to clarify that change tracking typically does not perform additional formatting for types like DateTime. Therefore, when you input as a JavaScript Date Object, there might be a problem with the old and new values having different formats.

Upon my testing, I found that this issue arises due to the use of different database services. The problem occurs when the we use @cap-js/sqlite or @cap-js/hana. Using the old database service like sqlite3 does not exhibit the aforementioned issue.

I have already raised an issue with the cds-dbs team regarding this situation and am awaiting their response.

Best Regards,
Wenjun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author action Need the actions taken by an author
Projects
None yet
Development

No branches or pull requests

2 participants