MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / extractTableNames

Function extractTableNames

packages/core/src/utils/sql.ts:90–124  ·  view source on GitHub ↗
(sql: string)

Source from the content-addressed store, hash-verified

88}
89
90function extractTableNames(sql: string): string[] {
91 const tables: string[] = [];
92 TOKEN_RE.lastIndex = 0;
93 let match: RegExpExecArray | null;
94
95 while ((match = TOKEN_RE.exec(sql)) !== null) {
96 if (match[1] || match[2]) {
97 tables.push((match[1] || match[2])!);
98 continue;
99 }
100
101 const rest = sql.slice(match.index + match[0].length);
102
103 const subqueryMatch = SUBQUERY_SELECT_RE.exec(rest);
104 if (subqueryMatch?.[1]) {
105 tables.push(subqueryMatch[1]);
106 TOKEN_RE.lastIndex = match.index + match[0].length + subqueryMatch[0].length;
107 continue;
108 }
109
110 const tableMatch = QUOTED_OR_PLAIN_TABLE_RE.exec(rest);
111 if (!tableMatch) continue;
112 tables.push(tableMatch[0]);
113
114 let afterTable = rest.slice(tableMatch[0].length);
115 let commaMatch: RegExpExecArray | null;
116 while ((commaMatch = COMMA_TABLE_RE.exec(afterTable)) !== null) {
117 if (!commaMatch[1]) break;
118 tables.push(commaMatch[1]);
119 afterTable = afterTable.slice(commaMatch[0].length);
120 }
121 }
122
123 return tables;
124}
125
126function truncate(summary: string): string {
127 if (summary.length <= MAX_SUMMARY_LENGTH) {

Callers 1

getSqlQuerySummaryFunction · 0.85

Calls 3

execMethod · 0.80
pushMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected