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 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-28 22:00:06 +08:00
parent a6c2e2ccc2
commit cf9976f605
2 changed files with 7 additions and 3 deletions

View File

@@ -339,7 +339,11 @@ const SQL_KEYWORDS = new Set([
'IF', 'IF',
'CURRENT_TIMESTAMP', 'CURRENT_TIMESTAMP',
'NOW', 'NOW',
'GETDATE' 'GETDATE',
// ==================== Timezone Expression ====================
'AT',
'ZONE'
]) ])
/** /**

View File

@@ -46,8 +46,8 @@ describe('PostgreSqlDialect', () => {
}) })
describe('currentTimestamp', () => { describe('currentTimestamp', () => {
it('should return CURRENT_TIMESTAMP', () => { it('should return explicit UTC timestamp expression', () => {
expect(dialect.currentTimestamp()).toBe('CURRENT_TIMESTAMP') expect(dialect.currentTimestamp()).toBe("(NOW() AT TIME ZONE 'UTC')")
}) })
}) })