mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 09:37:54 +01:00
Removed unused Table code
- Deprecated Table#execute and Table#executeUnsafe - Removed Table#addColumns and Table#removeColumns - Removed now unused tables.move.TransferTable
This commit is contained in:
parent
a4395c9076
commit
68d65c0748
@ -55,7 +55,7 @@ public abstract class Table {
|
|||||||
|
|
||||||
protected void createTable(String sql) throws DBInitException {
|
protected void createTable(String sql) throws DBInitException {
|
||||||
try {
|
try {
|
||||||
execute(sql);
|
db.execute(sql);
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
throw new DBInitException("Failed to create table: " + tableName, e);
|
throw new DBInitException("Failed to create table: " + tableName, e);
|
||||||
}
|
}
|
||||||
@ -82,7 +82,9 @@ public abstract class Table {
|
|||||||
*
|
*
|
||||||
* @param statementString Statement to execute in the database.
|
* @param statementString Statement to execute in the database.
|
||||||
* @return true if rows were updated.
|
* @return true if rows were updated.
|
||||||
|
* @deprecated Use {@code db.execute(statements)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
protected boolean execute(String statementString) {
|
protected boolean execute(String statementString) {
|
||||||
return db.execute(statementString);
|
return db.execute(statementString);
|
||||||
}
|
}
|
||||||
@ -91,7 +93,9 @@ public abstract class Table {
|
|||||||
* Used to execute statements while possible exceptions are suppressed.
|
* Used to execute statements while possible exceptions are suppressed.
|
||||||
*
|
*
|
||||||
* @param statements SQL statements to setUp
|
* @param statements SQL statements to setUp
|
||||||
|
* @deprecated Use {@code db.executeUnsafe(statements)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
protected void executeUnsafe(String... statements) {
|
protected void executeUnsafe(String... statements) {
|
||||||
db.executeUnsafe(statements);
|
db.executeUnsafe(statements);
|
||||||
}
|
}
|
||||||
@ -113,28 +117,7 @@ public abstract class Table {
|
|||||||
* Removes all data from the table.
|
* Removes all data from the table.
|
||||||
*/
|
*/
|
||||||
public void removeAllData() {
|
public void removeAllData() {
|
||||||
execute("DELETE FROM " + tableName);
|
db.execute("DELETE FROM " + tableName);
|
||||||
}
|
|
||||||
|
|
||||||
protected void addColumns(String... columnInfo) {
|
|
||||||
for (int i = 0; i < columnInfo.length; i++) {
|
|
||||||
columnInfo[i] = "ALTER TABLE " + tableName + " ADD " + (supportsMySQLQueries ? "" : "COLUMN ") + columnInfo[i];
|
|
||||||
}
|
|
||||||
executeUnsafe(columnInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void removeColumns(String... columnNames) {
|
|
||||||
if (supportsMySQLQueries) {
|
|
||||||
StringBuilder sqlBuild = new StringBuilder();
|
|
||||||
sqlBuild.append("ALTER TABLE ").append(tableName);
|
|
||||||
for (int i = 0; i < columnNames.length; i++) {
|
|
||||||
sqlBuild.append(" DROP COLUMN ").append(columnNames[i]);
|
|
||||||
if (i < columnNames.length - 1) {
|
|
||||||
sqlBuild.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
executeUnsafe(sqlBuild.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Player Analytics (Plan).
|
|
||||||
*
|
|
||||||
* Plan is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Plan is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables.move;
|
|
||||||
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.Table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract table used for transferring a whole table to a new table.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class TransferTable extends Table {
|
|
||||||
|
|
||||||
public TransferTable(SQLDB db) {
|
|
||||||
super("", db);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createTable() {
|
|
||||||
throw new IllegalStateException("Method not supposed to be used on this table.");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renameTable(String from, String to) {
|
|
||||||
String sql = supportsMySQLQueries ?
|
|
||||||
"RENAME TABLE " + from + " TO " + to :
|
|
||||||
"ALTER TABLE " + from + " RENAME TO " + to;
|
|
||||||
execute(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void dropTable(String name) {
|
|
||||||
execute(TableSqlParser.dropTable(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user