mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 17:47:38 +01:00
Fixed reserved keyword being used for a column name
row_number is apparently a function in MySQL.
This commit is contained in:
parent
c6507016cd
commit
ad85679899
@ -104,7 +104,7 @@ public class StorePlayerTableResultTransaction extends ThrowawayTransaction {
|
||||
String sql = DELETE_FROM + TABLE_NAME +
|
||||
WHERE + TABLE_ID + "=?" +
|
||||
AND + USER_UUID + "=?" +
|
||||
AND + ROW_NUMBER + ">=?"; // Since row count is zero indexed and afterRow is size the value should be removed.
|
||||
AND + TABLE_ROW + ">=?"; // Since row count is zero indexed and afterRow is size the value should be removed.
|
||||
|
||||
execute(new ExecStatement(sql) {
|
||||
@Override
|
||||
@ -124,7 +124,7 @@ public class StorePlayerTableResultTransaction extends ThrowawayTransaction {
|
||||
VALUE_2 + ',' +
|
||||
VALUE_3 + ',' +
|
||||
VALUE_4 + ',' +
|
||||
ROW_NUMBER +
|
||||
TABLE_ROW +
|
||||
") VALUES (?,?,?,?,?,?,?)";
|
||||
|
||||
execute(new ExecBatchStatement(sql) {
|
||||
@ -161,7 +161,7 @@ public class StorePlayerTableResultTransaction extends ThrowawayTransaction {
|
||||
VALUE_4 + "=?" +
|
||||
WHERE + TABLE_ID + "=?" +
|
||||
AND + USER_UUID + "=?" +
|
||||
AND + ROW_NUMBER + "=?";
|
||||
AND + TABLE_ROW + "=?";
|
||||
execute(new ExecBatchStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
@ -190,7 +190,7 @@ public class StorePlayerTableResultTransaction extends ThrowawayTransaction {
|
||||
}
|
||||
|
||||
private Query<Integer> currentRowCount(Integer tableID) {
|
||||
String sql = SELECT + "COALESCE(MAX(" + ROW_NUMBER + "), -1) as m" +
|
||||
String sql = SELECT + "COALESCE(MAX(" + TABLE_ROW + "), -1) as m" +
|
||||
FROM + TABLE_NAME +
|
||||
WHERE + TABLE_ID + "=?" +
|
||||
AND + USER_UUID + "=?";
|
||||
|
@ -101,7 +101,7 @@ public class StoreServerTableResultTransaction extends ThrowawayTransaction {
|
||||
String sql = DELETE_FROM + TABLE_NAME +
|
||||
WHERE + TABLE_ID + "=?" +
|
||||
AND + SERVER_UUID + "=?" +
|
||||
AND + ROW_NUMBER + ">=?"; // Since row count is zero indexed and afterRow is size the value should be removed.
|
||||
AND + TABLE_ROW + ">=?"; // Since row count is zero indexed and afterRow is size the value should be removed.
|
||||
|
||||
execute(new ExecStatement(sql) {
|
||||
@Override
|
||||
@ -122,7 +122,7 @@ public class StoreServerTableResultTransaction extends ThrowawayTransaction {
|
||||
VALUE_3 + ',' +
|
||||
VALUE_4 + ',' +
|
||||
VALUE_5 + ',' +
|
||||
ROW_NUMBER +
|
||||
TABLE_ROW +
|
||||
") VALUES (?,?,?,?,?,?,?,?)";
|
||||
|
||||
execute(new ExecBatchStatement(sql) {
|
||||
@ -160,7 +160,7 @@ public class StoreServerTableResultTransaction extends ThrowawayTransaction {
|
||||
VALUE_5 + "=?" +
|
||||
WHERE + TABLE_ID + "=?" +
|
||||
AND + SERVER_UUID + "=?" +
|
||||
AND + ROW_NUMBER + "=?";
|
||||
AND + TABLE_ROW + "=?";
|
||||
execute(new ExecBatchStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
@ -189,7 +189,7 @@ public class StoreServerTableResultTransaction extends ThrowawayTransaction {
|
||||
}
|
||||
|
||||
private Query<Integer> currentRowCount(Integer tableID) {
|
||||
String sql = SELECT + "COALESCE(MAX(" + ROW_NUMBER + "), -1) as m" +
|
||||
String sql = SELECT + "COALESCE(MAX(" + TABLE_ROW + "), -1) as m" +
|
||||
FROM + TABLE_NAME +
|
||||
WHERE + TABLE_ID + "=?" +
|
||||
AND + SERVER_UUID + "=?";
|
||||
|
@ -179,8 +179,8 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
new UserInfoHostnamePatch(),
|
||||
new ServerIsProxyPatch(),
|
||||
new UserInfoHostnameAllowNullPatch(),
|
||||
new ServerTableValuesRowNumberPatch(),
|
||||
new PlayerTableValuesRowNumberPatch(),
|
||||
new ServerTableRowPatch(),
|
||||
new PlayerTableRowPatch(),
|
||||
new ExtensionTableProviderValuesForPatch()
|
||||
};
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class ExtensionPlayerTableValueTable {
|
||||
public static final String TABLE_ID = "table_id";
|
||||
public static final String USER_UUID = "uuid";
|
||||
|
||||
public static final String ROW_NUMBER = "row_number";
|
||||
public static final String TABLE_ROW = "table_row";
|
||||
// All values can be null
|
||||
public static final String VALUE_1 = "col_1_value";
|
||||
public static final String VALUE_2 = "col_2_value";
|
||||
@ -50,7 +50,7 @@ public class ExtensionPlayerTableValueTable {
|
||||
return CreateTableBuilder.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(USER_UUID, Sql.varchar(36)).notNull()
|
||||
.column(ROW_NUMBER, INT).notNull().defaultValue("0")
|
||||
.column(TABLE_ROW, INT).notNull().defaultValue("0")
|
||||
.column(VALUE_1, Sql.varchar(250))
|
||||
.column(VALUE_2, Sql.varchar(250))
|
||||
.column(VALUE_3, Sql.varchar(250))
|
||||
|
@ -35,7 +35,7 @@ public class ExtensionServerTableValueTable {
|
||||
public static final String TABLE_ID = "table_id";
|
||||
public static final String SERVER_UUID = "uuid";
|
||||
|
||||
public static final String ROW_NUMBER = "row_number";
|
||||
public static final String TABLE_ROW = "table_row";
|
||||
// All values can be null
|
||||
public static final String VALUE_1 = "col_1_value";
|
||||
public static final String VALUE_2 = "col_2_value";
|
||||
@ -51,7 +51,7 @@ public class ExtensionServerTableValueTable {
|
||||
return CreateTableBuilder.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(SERVER_UUID, Sql.varchar(36)).notNull()
|
||||
.column(ROW_NUMBER, INT).notNull().defaultValue("0")
|
||||
.column(TABLE_ROW, INT).notNull().defaultValue("0")
|
||||
.column(VALUE_1, Sql.varchar(250))
|
||||
.column(VALUE_2, Sql.varchar(250))
|
||||
.column(VALUE_3, Sql.varchar(250))
|
||||
|
@ -32,14 +32,14 @@ import java.util.Map;
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerTableValueTable.ID;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerTableValueTable.TABLE_ID;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.ROW_NUMBER;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.TABLE_NAME;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.TABLE_ROW;
|
||||
|
||||
public class PlayerTableValuesRowNumberPatch extends Patch {
|
||||
public class PlayerTableRowPatch extends Patch {
|
||||
|
||||
@Override
|
||||
public boolean hasBeenApplied() {
|
||||
return hasColumn(TABLE_NAME, ROW_NUMBER)
|
||||
return hasColumn(TABLE_NAME, TABLE_ROW)
|
||||
&& tableRowIdsAreUniquePerTableId();
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class PlayerTableValuesRowNumberPatch extends Patch {
|
||||
String columnCountPerTableSql = SELECT +
|
||||
TABLE_ID + ",COUNT(1) as c" +
|
||||
FROM + TABLE_NAME +
|
||||
WHERE + ROW_NUMBER + "=?" +
|
||||
WHERE + TABLE_ROW + "=?" +
|
||||
GROUP_BY + TABLE_ID;
|
||||
return query(new QueryStatement<Boolean>(columnCountPerTableSql) {
|
||||
@Override
|
||||
@ -67,8 +67,8 @@ public class PlayerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
@Override
|
||||
protected void applyPatch() {
|
||||
if (!hasColumn(TABLE_NAME, ROW_NUMBER)) {
|
||||
addColumn(TABLE_NAME, ROW_NUMBER + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
if (!hasColumn(TABLE_NAME, TABLE_ROW)) {
|
||||
addColumn(TABLE_NAME, TABLE_ROW + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
}
|
||||
|
||||
updateRowIds();
|
||||
@ -76,7 +76,7 @@ public class PlayerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
private void updateRowIds() {
|
||||
String updateRowId = "UPDATE " + TABLE_NAME + " SET " +
|
||||
ROW_NUMBER + "=?" +
|
||||
TABLE_ROW + "=?" +
|
||||
WHERE + ID + "=?";
|
||||
for (List<Integer> rowIds : fetchTableRowIds().values()) {
|
||||
execute(new ExecBatchStatement(updateRowId) {
|
@ -33,11 +33,11 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.ID;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.*;
|
||||
|
||||
public class ServerTableValuesRowNumberPatch extends Patch {
|
||||
public class ServerTableRowPatch extends Patch {
|
||||
|
||||
@Override
|
||||
public boolean hasBeenApplied() {
|
||||
return hasColumn(TABLE_NAME, ROW_NUMBER)
|
||||
return hasColumn(TABLE_NAME, TABLE_ROW)
|
||||
&& tableRowIdsAreUniquePerTableId();
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class ServerTableValuesRowNumberPatch extends Patch {
|
||||
String columnCountPerTableSql = SELECT +
|
||||
TABLE_ID + ",COUNT(1) as c" +
|
||||
FROM + TABLE_NAME +
|
||||
WHERE + ROW_NUMBER + "=?" +
|
||||
WHERE + TABLE_ROW + "=?" +
|
||||
GROUP_BY + TABLE_ID;
|
||||
return query(new QueryStatement<Boolean>(columnCountPerTableSql) {
|
||||
@Override
|
||||
@ -65,8 +65,8 @@ public class ServerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
@Override
|
||||
protected void applyPatch() {
|
||||
if (!hasColumn(TABLE_NAME, ROW_NUMBER)) {
|
||||
addColumn(TABLE_NAME, ROW_NUMBER + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
if (!hasColumn(TABLE_NAME, TABLE_ROW)) {
|
||||
addColumn(TABLE_NAME, TABLE_ROW + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
}
|
||||
|
||||
updateRowIds();
|
||||
@ -74,7 +74,7 @@ public class ServerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
private void updateRowIds() {
|
||||
String updateRowId = "UPDATE " + TABLE_NAME + " SET " +
|
||||
ROW_NUMBER + "=?" +
|
||||
TABLE_ROW + "=?" +
|
||||
WHERE + ID + "=?";
|
||||
for (List<Integer> rowIds : fetchTableRowIds().values()) {
|
||||
execute(new ExecBatchStatement(updateRowId) {
|
Loading…
Reference in New Issue
Block a user