mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Fix issues if there were too many migrations to run. Escape SQL values
This commit is contained in:
parent
8920e7e2f9
commit
012a0d173c
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user