(sql: string)
| 88 | } |
| 89 | |
| 90 | function 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 | |
| 126 | function truncate(summary: string): string { |
| 127 | if (summary.length <= MAX_SUMMARY_LENGTH) { |
no test coverage detected