Fix issues if there were too many migrations to run. Escape SQL values

This commit is contained in:
ceze88 2023-08-02 18:31:04 +02:00
parent 8920e7e2f9
commit 012a0d173c
2 changed files with 3 additions and 3 deletions

View File

@ -188,7 +188,7 @@ public class DataManager {
// Migrate the data
for (DataMigration dataMigration : requiredMigrations) {
dataMigration.migrate(databaseConnector, getTablePrefix());
dataMigration.migrate(connection, getTablePrefix());
}
// Set the new current migration to be the highest migrated to

View File

@ -23,7 +23,7 @@ public abstract class DataMigration {
this.revision = revision;
}
public abstract void migrate(DatabaseConnector connector, String tablePrefix) throws SQLException;
public abstract void migrate(Connection connection, String tablePrefix) throws SQLException;
/**
* @return the revision number of this migration
@ -99,7 +99,7 @@ public abstract class DataMigration {
if (value == null) {
insertQuery.append("NULL");
} else if (value instanceof String || value instanceof Timestamp) {
insertQuery.append("'").append(value).append("'");
insertQuery.append("'").append(value instanceof String ? ((String) value).replaceAll("'", "''") : value).append("'");
} else {
insertQuery.append(value);
}