MCPcopy
hub / github.com/chartdb/chartdb / escapeSQLComment

Function escapeSQLComment

src/lib/data/sql-export/cross-dialect/common.ts:56–73  ·  view source on GitHub ↗
(comment: string)

Source from the content-addressed store, hash-verified

54}
55
56export function escapeSQLComment(comment: string): string {
57 if (!comment) {
58 return '';
59 }
60
61 // Escape single quotes by doubling them
62 let escaped = comment.replace(/'/g, "''");
63
64 // Replace newlines with spaces to prevent breaking SQL syntax
65 // Some databases support multi-line comments with specific syntax,
66 // but for maximum compatibility, we'll replace newlines with spaces
67 escaped = escaped.replace(/[\r\n]+/g, ' ');
68
69 // Trim any excessive whitespace
70 escaped = escaped.replace(/\s+/g, ' ').trim();
71
72 return escaped;
73}
74
75export function formatTableComment(comment: string): string {
76 if (!comment) {

Callers 2

exportBaseSQLFunction · 0.90
exportPostgreSQLToMySQLFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected