Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Fixed remaining issues with PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Mar 31, 2017
1 parent eea763c commit c00748d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/hm/achievement/db/PooledRequestsSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ private void batchRequestsForMultipleCategory(Statement st, MultipleAchievements
if (plugin.getDatabaseManager().getDatabaseType() == DatabaseType.POSTGRESQL) {
st.addBatch("INSERT INTO " + plugin.getDatabaseManager().getTablePrefix() + category.toDBName()
+ " VALUES ('" + entry.getKey().substring(0, 36) + "', '" + entry.getKey().substring(36) + "', "
+ entry.getValue() + ") ON CONFLICT (playername, '" + category.toSubcategoryDBName()
+ "') DO UPDATE SET (" + category.toDBName() + ")=(" + entry.getValue() + ")");
+ entry.getValue() + ") ON CONFLICT (playername, " + category.toSubcategoryDBName()
+ ") DO UPDATE SET (" + category.toDBName() + ")=(" + entry.getValue() + ")");
} else {
st.addBatch("REPLACE INTO " + plugin.getDatabaseManager().getTablePrefix() + category.toDBName()
+ " VALUES ('" + entry.getKey().substring(0, 36) + "', '" + entry.getKey().substring(36) + "', "
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/hm/achievement/db/SQLDatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ protected void performWrite() throws SQLException {
// PostgreSQL has no REPLACE operator. We have to use the INSERT ... ON CONFLICT construct,
// which is available for PostgreSQL 9.5+.
query = "INSERT INTO " + tablePrefix + category.toDBName() + " VALUES ('" + player.toString()
+ "', ?, " + statistic + ")" + " ON CONFLICT (playername, '" + subcategory
+ "') DO UPDATE SET (" + category.toDBName() + ")=('" + statistic + "')";
+ "', ?, " + statistic + ")" + " ON CONFLICT (playername, " + category.toSubcategoryDBName()
+ ") DO UPDATE SET (" + category.toDBName() + ")=('" + statistic + "')";
} else {
query = "REPLACE INTO " + tablePrefix + category.toDBName() + " VALUES ('" + player.toString()
+ "', ?, " + statistic + ")";
Expand Down

0 comments on commit c00748d

Please sign in to comment.