diff --git a/sqlite/lib/SQLiteService.js b/sqlite/lib/SQLiteService.js index deab9fabe..731fe10ee 100644 --- a/sqlite/lib/SQLiteService.js +++ b/sqlite/lib/SQLiteService.js @@ -221,7 +221,7 @@ class SQLiteService extends SQLService { ...super.InputConverters, // The following allows passing in ISO strings with non-zulu // timezones and converts them into zulu dates and times - Date: e => e === '?' ? e : `strftime('%Y-%m-%d',${e})`, + Date: e => `strftime('%Y-%m-%d',${e})`, Time: e => e === '?' ? e : `strftime('%H:%M:%S',${e})`, // Both, DateTimes and Timestamps are canonicalized to ISO strings with // ms precision to allow safe comparisons, also to query {val}s in where clauses diff --git a/test/compliance/UPDATE.test.js b/test/compliance/UPDATE.test.js index 8c90cb110..696ab1d89 100644 --- a/test/compliance/UPDATE.test.js +++ b/test/compliance/UPDATE.test.js @@ -119,6 +119,16 @@ describe('UPDATE', () => { }) }) + + test('Date object for Date field', async () => { + const { date } = cds.entities('basic.literals') + await UPDATE(date).with({date: new Date("2025-01-02")}) + + const result = await SELECT.from(date) + expect(result.length).to.eq(1) + expect(result[0].date).to.be.equal('2025-01-02') + }) + describe('where', () => { test('flat with or on key', async () => { const insert = await cds.run( diff --git a/test/compliance/resources/db/data/basic.literals-date.csv b/test/compliance/resources/db/data/basic.literals-date.csv new file mode 100644 index 000000000..7aaf16753 --- /dev/null +++ b/test/compliance/resources/db/data/basic.literals-date.csv @@ -0,0 +1,2 @@ +date; +1970-02-02; \ No newline at end of file