fix: Fixed GH-3492, Fixed the SQL error in the isTableExists method of MariaDBSchemaValidator.

Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
(cherry picked from commit b925c50f04)
This commit is contained in:
Sun Yuhan
2025-06-10 16:05:51 +08:00
committed by Spring Builds
parent 512ae893d2
commit 95ea7f2222

View File

@@ -45,12 +45,11 @@ public class MariaDBSchemaValidator {
private boolean isTableExists(String schemaName, String tableName) {
// schema and table are expected to be escaped
String sql = String.format(
"SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s",
(schemaName == null) ? "SCHEMA()" : schemaName, tableName);
String sql = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
try {
// Query for a single integer value, if it exists, table exists
this.jdbcTemplate.queryForObject(sql, Integer.class);
this.jdbcTemplate.queryForObject(sql, Integer.class, (schemaName == null) ? "SCHEMA()" : schemaName,
tableName);
return true;
}
catch (DataAccessException e) {