[Fix] Fix MySQL query for "Has Column"

MySQL query for has column did not take database name into account.
This means that a database with multiple Plan databases would provide
wrong results for the Patch system, leading to patch failiure

Affected issues: Fixes #732
This commit is contained in:
Rsl1122 2018-09-23 17:51:36 +03:00
parent cbb45bf49d
commit d1d2753422

View File

@ -52,11 +52,12 @@ public abstract class Patch {
protected boolean hasColumn(String tableName, String columnName) { protected boolean hasColumn(String tableName, String columnName) {
return usingMySQL ? return usingMySQL ?
query(new QueryStatement<Boolean>("SELECT * FROM information_schema.COLUMNS" + query(new QueryStatement<Boolean>("SELECT * FROM information_schema.COLUMNS" +
" WHERE TABLE_NAME=? AND COLUMN_NAME=?") { " WHERE TABLE_NAME=? AND COLUMN_NAME=? AND TABLE_SCHEMA=?") {
@Override @Override
public void prepare(PreparedStatement statement) throws SQLException { public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, tableName); statement.setString(1, tableName);
statement.setString(2, columnName); statement.setString(2, columnName);
statement.setString(3, Settings.DB_DATABASE.toString());
} }
@Override @Override