Browse Source

feat(perf): Add Relay placeholder parsing support to SQL parser (#58944)

As of https://github.com/getsentry/relay/pull/2552 Relay sometimes
injects `{%s}` into the query. I didn't notice at the time that this
causes a SQL parse failure.

Closes JAVASCRIPT-2NQW.
George Gritsouk 1 year ago
parent
commit
aea1a60306

+ 1 - 0
static/app/views/starfish/utils/sqlish/SQLishParser.spec.tsx

@@ -28,6 +28,7 @@ describe('SQLishParser', function () {
       'flags | %s)', // Bitwise OR
       'flags ^ %s)', // Bitwise XOR
       'flags ~ %s)', // Bitwise NOT
+      'FROM temp{%s}', // Relay integer stripping
       '+ %s as count', // Arithmetic I
       '- %s as count', // Arithmetic II
       "ILIKE '\\_')", // Backslash

+ 1 - 1
static/app/views/starfish/utils/sqlish/sqlish.pegjs

@@ -36,4 +36,4 @@ Whitespace
   = Whitespace:[\n\t ]+ { return { type: 'Whitespace', content: Whitespace.join("") } }
 
 GenericToken
-  = GenericToken:[a-zA-Z0-9"'`_\-.=><:,*;!\[\]?$%|/\\@#&~^+]+ { return { type: 'GenericToken', content: GenericToken.join('') } }
+  = GenericToken:[a-zA-Z0-9"'`_\-.=><:,*;!\[\]?$%|/\\@#&~^+{}]+ { return { type: 'GenericToken', content: GenericToken.join('') } }