(comment: string)
| 54 | } |
| 55 | |
| 56 | export 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 | |
| 75 | export function formatTableComment(comment: string): string { |
| 76 | if (!comment) { |
no outgoing calls
no test coverage detected