File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " emdash " : patch
3+ ---
4+
5+ Fixes Postgres rate-limit queries by quoting the reserved ` window ` column name.
Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ export async function checkRateLimit(
6363
6464 // Atomic upsert: insert or increment, return current count
6565 const result = await sql < { count : number } > `
66- INSERT INTO _emdash_rate_limits (key, window, count)
66+ INSERT INTO _emdash_rate_limits (key, " window" , count)
6767 VALUES (${ key } , ${ windowStart } , 1)
68- ON CONFLICT (key, window)
68+ ON CONFLICT (key, " window" )
6969 DO UPDATE SET count = _emdash_rate_limits.count + 1
7070 RETURNING count
7171 ` . execute ( db ) ;
@@ -179,7 +179,7 @@ export async function cleanupExpiredRateLimits(
179179 const cutoff = new Date ( Date . now ( ) - maxAgeSeconds * 1000 ) . toISOString ( ) ;
180180
181181 const result = await sql `
182- DELETE FROM _emdash_rate_limits WHERE window < ${ cutoff }
182+ DELETE FROM _emdash_rate_limits WHERE " window" < ${ cutoff }
183183 ` . execute ( db ) ;
184184
185185 return Number ( result . numAffectedRows ?? 0 ) ;
You can’t perform that action at this time.
0 commit comments