* Check if a SQL statement already has a LIMIT clause. * Strips comments and string literals first to avoid false positives.
(sql: string)
| 18 | * Strips comments and string literals first to avoid false positives. |
| 19 | */ |
| 20 | static hasLimitClause(sql: string): boolean { |
| 21 | // Strip comments and strings to avoid matching LIMIT inside them |
| 22 | const cleanedSQL = stripCommentsAndStrings(sql); |
| 23 | // Detect LIMIT clause - handles literal numbers and parameter placeholders ($1, ?, @p1) |
| 24 | const limitRegex = /\blimit\s+(?:\d+|\$\d+|\?|@p\d+)/i; |
| 25 | return limitRegex.test(cleanedSQL); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Check if a SQL statement already has a TOP clause (SQL Server). |
no test coverage detected