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

Method hasTopClause

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

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

(sql: string)

Source from the content-addressed store, hash-verified

30 * Strips comments and string literals first to avoid false positives.
31 */
32 static hasTopClause(sql: string): boolean {
33 // Strip comments and strings to avoid matching TOP inside them
34 const cleanedSQL = stripCommentsAndStrings(sql);
35 // Simple regex to detect TOP clause - handles most common cases
36 const topRegex = /\bselect\s+top\s+\d+/i;
37 return topRegex.test(cleanedSQL);
38 }
39
40 /**
41 * Extract existing LIMIT value from SQL if present.

Callers

nothing calls this directly

Calls 1

stripCommentsAndStringsFunction · 0.85

Tested by

no test coverage detected