From cf9976f605f6a13cb5a362ab121b5ace2ae6b759 Mon Sep 17 00:00:00 2001 From: Misaka Date: Tue, 28 Apr 2026 22:00:06 +0800 Subject: [PATCH] fix: add AT and ZONE to PostgreSQL SQL keywords for prepareSql The prepareSql function quotes any word not in SQL_KEYWORDS as an identifier. Since AT and ZONE were missing from the set, the expression (NOW() AT TIME ZONE 'UTC') was mangled into (NOW() "AT" TIME "ZONE" 'UTC'), causing INSERT failures on PostgreSQL. Co-Authored-By: Claude Opus 4.6 --- src/main/services/database/postgresql.ts | 6 +++++- tests/unit/dialects/postgresql-dialect.test.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/services/database/postgresql.ts b/src/main/services/database/postgresql.ts index 829785d..79ef9f7 100644 --- a/src/main/services/database/postgresql.ts +++ b/src/main/services/database/postgresql.ts @@ -339,7 +339,11 @@ const SQL_KEYWORDS = new Set([ 'IF', 'CURRENT_TIMESTAMP', 'NOW', - 'GETDATE' + 'GETDATE', + + // ==================== Timezone Expression ==================== + 'AT', + 'ZONE' ]) /** diff --git a/tests/unit/dialects/postgresql-dialect.test.ts b/tests/unit/dialects/postgresql-dialect.test.ts index e2f58e1..bbcecb8 100644 --- a/tests/unit/dialects/postgresql-dialect.test.ts +++ b/tests/unit/dialects/postgresql-dialect.test.ts @@ -46,8 +46,8 @@ describe('PostgreSqlDialect', () => { }) describe('currentTimestamp', () => { - it('should return CURRENT_TIMESTAMP', () => { - expect(dialect.currentTimestamp()).toBe('CURRENT_TIMESTAMP') + it('should return explicit UTC timestamp expression', () => { + expect(dialect.currentTimestamp()).toBe("(NOW() AT TIME ZONE 'UTC')") }) })