MCPcopy Create free account
hub / github.com/bytebase/dbhub / scanDollarQuotedBlock

Function scanDollarQuotedBlock

src/utils/sql-parser.ts:104–117  ·  view source on GitHub ↗
(sql: string, i: number)

Source from the content-addressed store, hash-verified

102const dollarQuoteOpenRegex = /^\$([a-zA-Z_]\w*)?\$/;
103
104function scanDollarQuotedBlock(sql: string, i: number): SQLToken | null {
105 if (sql[i] !== "$") { return null; }
106 // $N where N is a digit is a positional parameter, not a dollar-quote
107 const next = sql[i + 1];
108 if (next >= "0" && next <= "9") { return null; }
109 const remaining = sql.substring(i);
110 const m = dollarQuoteOpenRegex.exec(remaining);
111 if (!m) { return null; }
112 const tag = m[0];
113 const bodyStart = i + tag.length;
114 const closeIdx = sql.indexOf(tag, bodyStart);
115 const end = closeIdx !== -1 ? closeIdx + tag.length : sql.length;
116 return { type: TokenType.QuotedBlock, end };
117}
118
119function scanBacktickQuotedIdentifier(sql: string, i: number): SQLToken | null {
120 if (sql[i] !== "`") { return null; }

Callers 1

scanTokenPostgresFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected