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

Method extractLimitValue

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

* Extract existing LIMIT value from SQL if present. * Strips comments and string literals first to avoid false positives.

(sql: string)

Source from the content-addressed store, hash-verified

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

Callers 1

applyLimitToQueryMethod · 0.95

Calls 1

stripCommentsAndStringsFunction · 0.85

Tested by

no test coverage detected