checkIfAppendLimitRequired() — supabase Function Reference
Architecture documentation for the checkIfAppendLimitRequired() function in SQLEditor.utils.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD 64a0b59f_f05e_f70e_222b_79edb442a130["checkIfAppendLimitRequired()"] 5429b87d_ef53_7e21_26c6_6b167a463ebc["SQLEditor()"] 5429b87d_ef53_7e21_26c6_6b167a463ebc -->|calls| 64a0b59f_f05e_f70e_222b_79edb442a130 6896e8f8_40ca_e4c1_b90f_e8414a5a4a65["suffixWithLimit()"] 6896e8f8_40ca_e4c1_b90f_e8414a5a4a65 -->|calls| 64a0b59f_f05e_f70e_222b_79edb442a130 style 64a0b59f_f05e_f70e_222b_79edb442a130 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/SQLEditor/SQLEditor.utils.ts lines 119–143
export const checkIfAppendLimitRequired = (sql: string, limit: number = 0) => {
// Remove lines and whitespaces to use for checking
const cleanedSql = sql.trim().replaceAll('\n', ' ').replaceAll(/\s+/g, ' ')
// Check how many queries
const regMatch = cleanedSql.matchAll(/[a-zA-Z]*[0-9]*[;]+/g)
const queries = new Array(...regMatch)
const indexSemiColon = cleanedSql.lastIndexOf(';')
const hasComments = cleanedSql.includes('--')
const hasMultipleQueries =
queries.length > 1 || (indexSemiColon > 0 && indexSemiColon !== cleanedSql.length - 1)
// Check if need to auto limit rows
const appendAutoLimit =
limit > 0 &&
!hasComments &&
!hasMultipleQueries &&
cleanedSql.toLowerCase().startsWith('select') &&
!cleanedSql.toLowerCase().match(/fetch\s+first/i) &&
!cleanedSql.match(/limit$/i) &&
!cleanedSql.match(/limit;$/i) &&
!cleanedSql.match(/limit [0-9]* offset [0-9]*[;]?$/i) &&
!cleanedSql.match(/limit [0-9]*[;]?$/i)
return { cleanedSql, appendAutoLimit }
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does checkIfAppendLimitRequired() do?
checkIfAppendLimitRequired() is a function in the supabase codebase.
What calls checkIfAppendLimitRequired()?
checkIfAppendLimitRequired() is called by 2 function(s): SQLEditor, suffixWithLimit.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free