mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Rename VARCHAR to varchar
This commit is contained in:
parent
5204d52d78
commit
268dae902f
@ -0,0 +1,39 @@
|
||||
package main.java.com.djrapitops.plan.database.sql;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
|
||||
public class Select extends SqlParser {
|
||||
|
||||
private int conditions = 0;
|
||||
|
||||
public Select(String start) {
|
||||
super(start);
|
||||
}
|
||||
|
||||
public static Select from(String table, String... columns) {
|
||||
Select parser = new Select("SELECT ");
|
||||
int size = columns.length;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (size > 1 && i > 0) {
|
||||
parser.append(", ");
|
||||
}
|
||||
parser.append(columns[i]);
|
||||
}
|
||||
|
||||
parser.append(" FROM ").append(table);
|
||||
Log.debug(parser.toString());
|
||||
return parser;
|
||||
}
|
||||
|
||||
public Select where(String... conditions) {
|
||||
append(" WHERE ");
|
||||
for (int i = 0; i < conditions.length; i++) {
|
||||
if (this.conditions > 0) {
|
||||
append(" AND ");
|
||||
}
|
||||
append("(").append(conditions[i]).append(")");
|
||||
this.conditions++;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@ -6,7 +6,11 @@ public class Sql {
|
||||
public static final String LONG = "bigint";
|
||||
public static final String BOOL = "boolean";
|
||||
|
||||
public static String VARCHAR(int length) {
|
||||
private Sql() {
|
||||
throw new IllegalStateException("Variable Class");
|
||||
}
|
||||
|
||||
public static String varchar(int length) {
|
||||
return "varchar("+length+")";
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,16 @@ public class TableSqlParser extends SqlParser {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for ALTER TABLE sql statements.
|
||||
*
|
||||
* @param column column to modify
|
||||
* @return TableSqlParser object
|
||||
*/
|
||||
public static TableSqlParser newColumn(String column, String type) {
|
||||
return new TableSqlParser("").column(column, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
append(")");
|
||||
|
@ -38,7 +38,7 @@ public class CommandUseTable extends Table {
|
||||
public boolean createTable() {
|
||||
try {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.column(columnCommand, Sql.VARCHAR(20)).notNull()
|
||||
.column(columnCommand, Sql.varchar(20)).notNull()
|
||||
.column(columnTimesUsed, Sql.INT).notNull()
|
||||
.toString()
|
||||
);
|
||||
|
@ -40,7 +40,7 @@ public class IPsTable extends UserIDTable {
|
||||
try {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.column(columnUserID, Sql.INT).notNull()
|
||||
.column(columnIP, Sql.VARCHAR(20)).notNull()
|
||||
.column(columnIP, Sql.varchar(20)).notNull()
|
||||
.foreignKey(columnUserID, usersTable.getTableName(), usersTable.getColumnID())
|
||||
.toString()
|
||||
);
|
||||
|
@ -45,7 +45,7 @@ public class KillsTable extends Table {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.column(columnKillerUserID, Sql.INT).notNull()
|
||||
.column(columnVictimUserID, Sql.INT).notNull()
|
||||
.column(columnWeapon, Sql.VARCHAR(30)).notNull()
|
||||
.column(columnWeapon, Sql.varchar(30)).notNull()
|
||||
.column(columnDate, Sql.LONG).notNull()
|
||||
.foreignKey(columnKillerUserID, usersTable.getTableName(), usersTable.getColumnID())
|
||||
.foreignKey(columnVictimUserID, usersTable.getTableName(), usersTable.getColumnID())
|
||||
|
@ -40,7 +40,7 @@ public class NicknamesTable extends UserIDTable {
|
||||
try {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.column(columnUserID, Sql.INT).notNull()
|
||||
.column(columnNick, Sql.VARCHAR(75)).notNull()
|
||||
.column(columnNick, Sql.varchar(75)).notNull()
|
||||
.column(columnCurrent, Sql.BOOL).notNull().defaultValue(false)
|
||||
.foreignKey(columnUserID, usersTable.getTableName(), usersTable.getColumnID())
|
||||
.toString()
|
||||
|
@ -37,8 +37,8 @@ public class SecurityTable extends Table {
|
||||
public boolean createTable() {
|
||||
try {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.column(columnUser, Sql.VARCHAR(100)).notNull().unique()
|
||||
.column(columnSaltedHash, Sql.VARCHAR(100)).notNull().unique()
|
||||
.column(columnUser, Sql.varchar(100)).notNull().unique()
|
||||
.column(columnSaltedHash, Sql.varchar(100)).notNull().unique()
|
||||
.column(columnPermLevel, Sql.INT).notNull()
|
||||
.toString()
|
||||
);
|
||||
|
@ -99,9 +99,9 @@ public class UsersTable extends Table {
|
||||
try {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.primaryKeyIDColumn(usingMySQL, columnID, Sql.INT)
|
||||
.column(columnUUID, Sql.VARCHAR(36)).notNull().unique()
|
||||
.column(columnGeolocation, Sql.VARCHAR(50)).notNull()
|
||||
.column(columnLastGM, Sql.VARCHAR(15)).notNull()
|
||||
.column(columnUUID, Sql.varchar(36)).notNull().unique()
|
||||
.column(columnGeolocation, Sql.varchar(50)).notNull()
|
||||
.column(columnLastGM, Sql.varchar(15)).notNull()
|
||||
.column(columnLastGMSwapTime, Sql.LONG).notNull()
|
||||
.column(columnPlayTime, Sql.LONG).notNull()
|
||||
.column(columnLoginTimes, Sql.INT).notNull()
|
||||
@ -110,10 +110,10 @@ public class UsersTable extends Table {
|
||||
.column(columnMobKills, Sql.INT).notNull()
|
||||
.column(columnRegistered, Sql.LONG).notNull()
|
||||
.column(columnOP, Sql.BOOL).notNull().defaultValue(false)
|
||||
.column(columnName, Sql.VARCHAR(16)).notNull()
|
||||
.column(columnName, Sql.varchar(16)).notNull()
|
||||
.column(columnBanned, Sql.BOOL).notNull().defaultValue(false)
|
||||
.column(columnContainsBukkitData, Sql.BOOL).notNull().defaultValue(false)
|
||||
.column(columnLastWorld, Sql.VARCHAR(255)).notNull()
|
||||
.column(columnLastWorld, Sql.varchar(255)).notNull()
|
||||
.column(columnLastWorldSwapTime, Sql.LONG).notNull()
|
||||
.primaryKey(usingMySQL, columnID)
|
||||
.toString()
|
||||
|
@ -43,7 +43,7 @@ public class WorldTable extends Table {
|
||||
try {
|
||||
execute(TableSqlParser.createTable(tableName)
|
||||
.primaryKeyIDColumn(usingMySQL, columnWorldId, Sql.INT)
|
||||
.column(columnWorldName, Sql.VARCHAR(100)).notNull()
|
||||
.column(columnWorldName, Sql.varchar(100)).notNull()
|
||||
.primaryKey(usingMySQL, columnWorldId)
|
||||
.toString()
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user