MCPcopy Index your code
hub / github.com/bytebase/dbhub / hasLimitClause

Method hasLimitClause

src/utils/sql-row-limiter.ts:20–26  ·  view source on GitHub ↗

* Check if a SQL statement already has a LIMIT clause. * Strips comments and string literals first to avoid false positives.

(sql: string)

Source from the content-addressed store, hash-verified

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).

Callers 1

Calls 1

stripCommentsAndStringsFunction · 0.85

Tested by

no test coverage detected