Rename CountQueryStatement to HasMoreThanZeroQueryStatement

This is to avoid confusion as the Query is of type Boolean instead of
Integer.
This commit is contained in:
Rsl1122 2019-01-26 10:57:50 +02:00
parent 9e496914b3
commit 019f75bafe
5 changed files with 14 additions and 14 deletions

View File

@ -24,15 +24,15 @@ import java.sql.SQLException;
*
* @author Rsl1122
*/
public abstract class CountQueryStatement extends QueryStatement<Boolean> {
public abstract class HasMoreThanZeroQueryStatement extends QueryStatement<Boolean> {
private String countColumnName = "c";
public CountQueryStatement(String sql) {
public HasMoreThanZeroQueryStatement(String sql) {
super(sql);
}
public CountQueryStatement(String sql, String countColumnName) {
public HasMoreThanZeroQueryStatement(String sql, String countColumnName) {
super(sql);
this.countColumnName = countColumnName;
}

View File

@ -17,7 +17,7 @@
package com.djrapitops.plan.db.patches;
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 java.sql.PreparedStatement;
@ -51,7 +51,7 @@ public class BadAFKThresholdValuePatch extends Patch {
SessionsTable.AFK_TIME +
" - (" + SessionsTable.SESSION_END + "-" + SessionsTable.SESSION_START +
")) < 5 AND " + SessionsTable.AFK_TIME + "!=0";
return query(new CountQueryStatement(sql, "found") {
return query(new HasMoreThanZeroQueryStatement(sql, "found") {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
/* Nothing to prepare */

View File

@ -16,7 +16,7 @@
*/
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 java.sql.PreparedStatement;
@ -35,7 +35,7 @@ public class H2SchemaQueries {
public static Query<Boolean> doesTableExist(String tableName) {
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=?";
return new CountQueryStatement(sql) {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName);
@ -46,7 +46,7 @@ public class H2SchemaQueries {
public static Query<Boolean> doesColumnExist(String tableName, String columnName) {
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.COLUMNS" +
" WHERE TABLE_NAME=? AND COLUMN_NAME=?";
return new CountQueryStatement(sql) {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName);

View File

@ -16,7 +16,7 @@
*/
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.QueryStatement;
@ -39,7 +39,7 @@ public class MySQLSchemaQueries {
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()";
return new CountQueryStatement(sql) {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName);
@ -83,7 +83,7 @@ public class MySQLSchemaQueries {
public static Query<Boolean> doesIndexExist(String indexName, String tableName) {
String sql = "SELECT COUNT(1) as c FROM INFORMATION_SCHEMA.STATISTICS " +
"WHERE table_schema=DATABASE() AND table_name=? AND index_name=?";
return new CountQueryStatement(sql) {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName);
@ -95,7 +95,7 @@ public class MySQLSchemaQueries {
public static Query<Boolean> doesColumnExist(String tableName, String columnName) {
String sql = "SELECT COUNT(1) as c FROM information_schema.COLUMNS" +
" WHERE TABLE_NAME=? AND COLUMN_NAME=? AND TABLE_SCHEMA=DATABASE()";
return new CountQueryStatement(sql) {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName);

View File

@ -16,7 +16,7 @@
*/
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.QueryAllStatement;
@ -37,7 +37,7 @@ public class SQLiteSchemaQueries {
public static Query<Boolean> doesTableExist(String tableName) {
String sql = "SELECT COUNT(1) as c FROM sqlite_master WHERE tbl_name=?";
return new CountQueryStatement(sql) {
return new HasMoreThanZeroQueryStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName);