DB Backup Bug

This commit is contained in:
Stefan Hardegger
2025-07-31 07:38:05 +02:00
parent 9e788c2018
commit 370bef2f07

View File

@@ -92,8 +92,27 @@ public class DatabaseManagementService {
sqlDump.append(value.toString());
} else {
// Handle all other types as strings (String, UUID, Timestamp, CLOB, TEXT, etc.)
// Escape single quotes and wrap in quotes
String escapedValue = value.toString().replace("'", "''");
String stringValue;
// Special handling for CLOB types
if (value instanceof Clob) {
Clob clob = (Clob) value;
try {
stringValue = clob.getSubString(1, (int) clob.length());
} catch (SQLException e) {
stringValue = value.toString();
}
} else {
stringValue = value.toString();
}
// Debug: log if we're dealing with a large content field
if (stringValue.length() > 1000) {
System.out.println("Processing large field (length: " + stringValue.length() + ") with quotes: " + stringValue.contains("'") + " type: " + value.getClass().getSimpleName());
}
// Escape single quotes by replacing ' with ''
String escapedValue = stringValue.replace("'", "''");
sqlDump.append("'").append(escapedValue).append("'");
}
}