Fixed bug with SQLite deletion not working.

This commit is contained in:
tastybento 2019-06-28 16:45:39 -07:00
parent 64f03bad04
commit a147f3fda7

View File

@ -205,9 +205,12 @@ public class SQLiteDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
dataObject.getCanonicalName() +
"` WHERE uniqueId = ?";
try (PreparedStatement preparedStatement = connection.prepareStatement(sb)) {
// UniqueId needs to be placed in quotes
preparedStatement.setString(1, "\"" + uniqueId + "\"");
preparedStatement.execute();
// UniqueId must not be placed in quotes
preparedStatement.setString(1, uniqueId);
int result = preparedStatement.executeUpdate();
if (result != 1) {
throw new SQLException("Delete did not affect any rows!");
}
} catch (Exception e) {
plugin.logError("Could not delete object " + dataObject.getCanonicalName() + " " + uniqueId + " " + e.getMessage());
}