* Extract existing TOP value from SQL if present (SQL Server). * Strips comments and string literals first to avoid false positives.
(sql: string)
| 56 | * Strips comments and string literals first to avoid false positives. |
| 57 | */ |
| 58 | static extractTopValue(sql: string): number | null { |
| 59 | // Strip comments and strings to avoid matching TOP inside them |
| 60 | const cleanedSQL = stripCommentsAndStrings(sql); |
| 61 | const topMatch = cleanedSQL.match(/\bselect\s+top\s+(\d+)/i); |
| 62 | if (topMatch) { |
| 63 | return parseInt(topMatch[1], 10); |
| 64 | } |
| 65 | return null; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Add or modify LIMIT clause in a SQL statement |
no test coverage detected