MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / addPaginationToQuery

Function addPaginationToQuery

frontend/src/lib/duckdb/utils.ts:37–47  ·  view source on GitHub ↗
(sql: string, limit: number, offset: number)

Source from the content-addressed store, hash-verified

35 * @returns Modified SQL query with pagination added
36 */
37export function addPaginationToQuery(sql: string, limit: number, offset: number): string {
38 const cleanedSQL = cleanSqlQuery(sql);
39 const noSemicolon = cleanedSQL.replace(';', '');
40
41 // Only add LIMIT if not already present
42 if (!noSemicolon.toUpperCase().includes("LIMIT")) {
43 return `${noSemicolon} LIMIT ${limit} OFFSET ${offset}`;
44 }
45
46 return sql;
47}
48
49/**
50 * Creates a COUNT query to get the total number of rows for a SELECT query

Callers 1

executePaginatedQueryFunction · 0.90

Calls 1

cleanSqlQueryFunction · 0.85

Tested by

no test coverage detected