Skip to content

Commit 72afd61

Browse files
logaretmclaude
andcommitted
fix(core): Avoid parse-time SyntaxError on Safari <16.4 in postgresjs
Closes #20433 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b045541 commit 72afd61

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/core/src/integrations/postgresjs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ export function _sanitizeSqlQuery(sqlQuery: string | undefined): string {
378378
.replace(/-?\b\d+\.?\d*[eE][+-]?\d+\b/g, '?') // Scientific notation
379379
.replace(/-?\b\d+\.\d+\b/g, '?') // Decimals
380380
.replace(/-?\.\d+\b/g, '?') // Decimals starting with dot
381-
.replace(/(?<!\$)-?\b\d+\b/g, '?') // Integers (NOT $n placeholders)
381+
// Constructed via `new RegExp` so the negative lookbehind is evaluated at
382+
// runtime. As a literal, it is a parse-time SyntaxError on Safari <16.4 —
383+
// which breaks any browser bundle that reaches this module via the core barrel.
384+
.replace(new RegExp('(?<!\\$)-?\\b\\d+\\b', 'g'), '?') // Integers (NOT $n placeholders)
382385
// Collapse IN clauses for cardinality (both ? and $n variants)
383386
.replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi, 'IN (?)')
384387
.replace(/\bIN\b\s*\(\s*\$\d+(?:\s*,\s*\$\d+)*\s*\)/gi, 'IN ($?)')

0 commit comments

Comments
 (0)