mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-26 19:17:43 +01:00
Rename CountQueryStatement to HasMoreThanZeroQueryStatement
This is to avoid confusion as the Query is of type Boolean instead of Integer.
This commit is contained in:
parent
9e496914b3
commit
019f75bafe
@ -24,15 +24,15 @@ import java.sql.SQLException;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public abstract class CountQueryStatement extends QueryStatement<Boolean> {
|
public abstract class HasMoreThanZeroQueryStatement extends QueryStatement<Boolean> {
|
||||||
|
|
||||||
private String countColumnName = "c";
|
private String countColumnName = "c";
|
||||||
|
|
||||||
public CountQueryStatement(String sql) {
|
public HasMoreThanZeroQueryStatement(String sql) {
|
||||||
super(sql);
|
super(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CountQueryStatement(String sql, String countColumnName) {
|
public HasMoreThanZeroQueryStatement(String sql, String countColumnName) {
|
||||||
super(sql);
|
super(sql);
|
||||||
this.countColumnName = countColumnName;
|
this.countColumnName = countColumnName;
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
package com.djrapitops.plan.db.patches;
|
package com.djrapitops.plan.db.patches;
|
||||||
|
|
||||||
import com.djrapitops.plan.db.SQLDB;
|
import com.djrapitops.plan.db.SQLDB;
|
||||||
import com.djrapitops.plan.db.access.CountQueryStatement;
|
import com.djrapitops.plan.db.access.HasMoreThanZeroQueryStatement;
|
||||||
import com.djrapitops.plan.db.sql.tables.SessionsTable;
|
import com.djrapitops.plan.db.sql.tables.SessionsTable;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -51,7 +51,7 @@ public class BadAFKThresholdValuePatch extends Patch {
|
|||||||
SessionsTable.AFK_TIME +
|
SessionsTable.AFK_TIME +
|
||||||
" - (" + SessionsTable.SESSION_END + "-" + SessionsTable.SESSION_START +
|
" - (" + SessionsTable.SESSION_END + "-" + SessionsTable.SESSION_START +
|
||||||
")) < 5 AND " + SessionsTable.AFK_TIME + "!=0";
|
")) < 5 AND " + SessionsTable.AFK_TIME + "!=0";
|
||||||
return query(new CountQueryStatement(sql, "found") {
|
return query(new HasMoreThanZeroQueryStatement(sql, "found") {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
/* Nothing to prepare */
|
/* Nothing to prepare */
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.db.sql.queries.schema;
|
package com.djrapitops.plan.db.sql.queries.schema;
|
||||||
|
|
||||||
import com.djrapitops.plan.db.access.CountQueryStatement;
|
import com.djrapitops.plan.db.access.HasMoreThanZeroQueryStatement;
|
||||||
import com.djrapitops.plan.db.access.Query;
|
import com.djrapitops.plan.db.access.Query;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -35,7 +35,7 @@ public class H2SchemaQueries {
|
|||||||
|
|
||||||
public static Query<Boolean> doesTableExist(String tableName) {
|
public static Query<Boolean> doesTableExist(String tableName) {
|
||||||
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=?";
|
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=?";
|
||||||
return new CountQueryStatement(sql) {
|
return new HasMoreThanZeroQueryStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
@ -46,7 +46,7 @@ public class H2SchemaQueries {
|
|||||||
public static Query<Boolean> doesColumnExist(String tableName, String columnName) {
|
public static Query<Boolean> doesColumnExist(String tableName, String columnName) {
|
||||||
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.COLUMNS" +
|
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.COLUMNS" +
|
||||||
" WHERE TABLE_NAME=? AND COLUMN_NAME=?";
|
" WHERE TABLE_NAME=? AND COLUMN_NAME=?";
|
||||||
return new CountQueryStatement(sql) {
|
return new HasMoreThanZeroQueryStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.db.sql.queries.schema;
|
package com.djrapitops.plan.db.sql.queries.schema;
|
||||||
|
|
||||||
import com.djrapitops.plan.db.access.CountQueryStatement;
|
import com.djrapitops.plan.db.access.HasMoreThanZeroQueryStatement;
|
||||||
import com.djrapitops.plan.db.access.Query;
|
import com.djrapitops.plan.db.access.Query;
|
||||||
import com.djrapitops.plan.db.access.QueryStatement;
|
import com.djrapitops.plan.db.access.QueryStatement;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class MySQLSchemaQueries {
|
|||||||
|
|
||||||
public static Query<Boolean> doesTableExist(String tableName) {
|
public static Query<Boolean> doesTableExist(String tableName) {
|
||||||
String sql = "SELECT COUNT(1) as c FROM information_schema.TABLES WHERE table_name=? AND TABLE_SCHEMA=DATABASE()";
|
String sql = "SELECT COUNT(1) as c FROM information_schema.TABLES WHERE table_name=? AND TABLE_SCHEMA=DATABASE()";
|
||||||
return new CountQueryStatement(sql) {
|
return new HasMoreThanZeroQueryStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
@ -83,7 +83,7 @@ public class MySQLSchemaQueries {
|
|||||||
public static Query<Boolean> doesIndexExist(String indexName, String tableName) {
|
public static Query<Boolean> doesIndexExist(String indexName, String tableName) {
|
||||||
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.STATISTICS " +
|
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.STATISTICS " +
|
||||||
"WHERE table_schema=DATABASE() AND table_name=? AND index_name=?";
|
"WHERE table_schema=DATABASE() AND table_name=? AND index_name=?";
|
||||||
return new CountQueryStatement(sql) {
|
return new HasMoreThanZeroQueryStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
@ -95,7 +95,7 @@ public class MySQLSchemaQueries {
|
|||||||
public static Query<Boolean> doesColumnExist(String tableName, String columnName) {
|
public static Query<Boolean> doesColumnExist(String tableName, String columnName) {
|
||||||
String sql = "SELECT COUNT(1) as c FROM information_schema.COLUMNS" +
|
String sql = "SELECT COUNT(1) as c FROM information_schema.COLUMNS" +
|
||||||
" WHERE TABLE_NAME=? AND COLUMN_NAME=? AND TABLE_SCHEMA=DATABASE()";
|
" WHERE TABLE_NAME=? AND COLUMN_NAME=? AND TABLE_SCHEMA=DATABASE()";
|
||||||
return new CountQueryStatement(sql) {
|
return new HasMoreThanZeroQueryStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.db.sql.queries.schema;
|
package com.djrapitops.plan.db.sql.queries.schema;
|
||||||
|
|
||||||
import com.djrapitops.plan.db.access.CountQueryStatement;
|
import com.djrapitops.plan.db.access.HasMoreThanZeroQueryStatement;
|
||||||
import com.djrapitops.plan.db.access.Query;
|
import com.djrapitops.plan.db.access.Query;
|
||||||
import com.djrapitops.plan.db.access.QueryAllStatement;
|
import com.djrapitops.plan.db.access.QueryAllStatement;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class SQLiteSchemaQueries {
|
|||||||
|
|
||||||
public static Query<Boolean> doesTableExist(String tableName) {
|
public static Query<Boolean> doesTableExist(String tableName) {
|
||||||
String sql = "SELECT COUNT(1) as c FROM sqlite_master WHERE tbl_name=?";
|
String sql = "SELECT COUNT(1) as c FROM sqlite_master WHERE tbl_name=?";
|
||||||
return new CountQueryStatement(sql) {
|
return new HasMoreThanZeroQueryStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
|
Loading…
Reference in New Issue
Block a user