mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-01 00:10:40 +01:00
Return true if database save executed.
Fixes bug where if no change was made it was reporting an error.
This commit is contained in:
parent
6a28ba0b1d
commit
7bfbfe78a3
@ -133,7 +133,8 @@ public class MongoDBDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
|||||||
// Set the options to upsert (update or insert if doc is not there)
|
// Set the options to upsert (update or insert if doc is not there)
|
||||||
FindOneAndReplaceOptions options = new FindOneAndReplaceOptions().upsert(true);
|
FindOneAndReplaceOptions options = new FindOneAndReplaceOptions().upsert(true);
|
||||||
// Do the deed
|
// Do the deed
|
||||||
completableFuture.complete(collection.findOneAndReplace(filter, document, options) != null);
|
collection.findOneAndReplace(filter, document, options);
|
||||||
|
completableFuture.complete(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.logError("Could not save object " + instance.getClass().getName() + " " + e.getMessage());
|
plugin.logError("Could not save object " + instance.getClass().getName() + " " + e.getMessage());
|
||||||
completableFuture.complete(false);
|
completableFuture.complete(false);
|
||||||
|
@ -169,7 +169,8 @@ public class SQLDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
|||||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sb)) {
|
try (PreparedStatement preparedStatement = connection.prepareStatement(sb)) {
|
||||||
preparedStatement.setString(1, toStore);
|
preparedStatement.setString(1, toStore);
|
||||||
preparedStatement.setString(2, toStore);
|
preparedStatement.setString(2, toStore);
|
||||||
completableFuture.complete(preparedStatement.execute());
|
preparedStatement.execute();
|
||||||
|
completableFuture.complete(true);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logError("Could not save object " + name + " " + e.getMessage());
|
plugin.logError("Could not save object " + name + " " + e.getMessage());
|
||||||
completableFuture.complete(false);
|
completableFuture.complete(false);
|
||||||
|
@ -73,7 +73,8 @@ public class PostgreSQLDatabaseHandler<T> extends SQLDatabaseHandler<T> {
|
|||||||
preparedStatement.setString(1, uniqueId); // INSERT
|
preparedStatement.setString(1, uniqueId); // INSERT
|
||||||
preparedStatement.setString(2, toStore); // INSERT
|
preparedStatement.setString(2, toStore); // INSERT
|
||||||
preparedStatement.setString(3, toStore); // ON CONFLICT
|
preparedStatement.setString(3, toStore); // ON CONFLICT
|
||||||
completableFuture.complete(preparedStatement.execute());
|
preparedStatement.execute();
|
||||||
|
completableFuture.complete(true);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logError("Could not save object " + instance.getClass().getName() + " " + e.getMessage());
|
plugin.logError("Could not save object " + instance.getClass().getName() + " " + e.getMessage());
|
||||||
completableFuture.complete(false);
|
completableFuture.complete(false);
|
||||||
|
@ -60,7 +60,8 @@ public class SQLiteDatabaseHandler<T> extends SQLDatabaseHandler<T> {
|
|||||||
preparedStatement.setString(1, toStore);
|
preparedStatement.setString(1, toStore);
|
||||||
preparedStatement.setString(2, ((DataObject)instance).getUniqueId());
|
preparedStatement.setString(2, ((DataObject)instance).getUniqueId());
|
||||||
preparedStatement.setString(3, toStore);
|
preparedStatement.setString(3, toStore);
|
||||||
completableFuture.complete(preparedStatement.execute());
|
preparedStatement.execute();
|
||||||
|
completableFuture.complete(true);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logError("Could not save object " + instance.getClass().getName() + " " + e.getMessage());
|
plugin.logError("Could not save object " + instance.getClass().getName() + " " + e.getMessage());
|
||||||
completableFuture.complete(false);
|
completableFuture.complete(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user