fix(sql-export): escape newlines and quotes in multi-line comments (#765)

This commit is contained in:
Jonathan Fishner
2025-07-16 15:18:52 +03:00
committed by GitHub
parent b35e17526b
commit f7f92903de
6 changed files with 60 additions and 10 deletions

View File

@@ -285,13 +285,13 @@ export const exportBaseSQL = ({
// Add table comment
if (table.comments) {
sqlScript += `COMMENT ON TABLE ${tableName} IS '${table.comments}';\n`;
sqlScript += `COMMENT ON TABLE ${tableName} IS '${table.comments.replace(/'/g, "''")}';\n`;
}
table.fields.forEach((field) => {
// Add column comment
if (field.comments) {
sqlScript += `COMMENT ON COLUMN ${tableName}.${field.name} IS '${field.comments}';\n`;
sqlScript += `COMMENT ON COLUMN ${tableName}.${field.name} IS '${field.comments.replace(/'/g, "''")}';\n`;
}
});