Skip to content

Missing DateTime to Date conversion during UPDATE with SQLite #1002

@stockbal

Description

@stockbal

Description of erroneous behaviour

I have the following CAP db model

entity Calculations : cuid, managed {
    calculatedOn : Date;
}

In my TypeScript Code I want to run the following UPDATE query

await UPDATE(Calculations, id).set({ calculatedOn: new Date() })

The update query is executed without issues, but afterwards, a SELECT on the updated row shows the following output

{
  "ID": "382fee26-370d-40d2-bd58-49faedc76faf",
  "calculatedOn": "2025-01-29T08:56:53.117Z"
}

instead of

{
  "ID": "382fee26-370d-40d2-bd58-49faedc76faf",
  "calculatedOn": "2025-01-29"
}

With @cap-js/sqlite and version <= 1.7.4 this automatic conversion still works. The behavior changed in 338e9f5. As the current implementation of @cap-js/hana still performs the conversion/cut-off during UPDATE I would expect the SQlite driver to behave the same way.

Detailed steps to reproduce

For example (→ replace by appropriate ones for your case):

  1. git clone https://github.com/stockbal/sqlite-issue-test
  2. npm ci
  3. npm run watch

Details about your project

Project https://github.com/stockbal/sqlite-issue-test
OData version v4
Node.js version v20.18.1
@sap/cds 8.7.0
@sap/cds-compiler 5.7.0
@sap/cds-dk 8.7.0
@cap-js/sqlite 1.7.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsqlite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions