* Extract existing LIMIT value from SQL if present. * Strips comments and string literals first to avoid false positives.
(sql: string)
| 42 | * Strips comments and string literals first to avoid false positives. |
| 43 | */ |
| 44 | static extractLimitValue(sql: string): number | null { |
| 45 | // Strip comments and strings to avoid matching LIMIT inside them |
| 46 | const cleanedSQL = stripCommentsAndStrings(sql); |
| 47 | const limitMatch = cleanedSQL.match(/\blimit\s+(\d+)/i); |
| 48 | if (limitMatch) { |
| 49 | return parseInt(limitMatch[1], 10); |
| 50 | } |
| 51 | return null; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Extract existing TOP value from SQL if present (SQL Server). |
no test coverage detected