Skip to content

Commit 95ea7f2

Browse files
sunyuhan1998spring-builds
authored andcommitted
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 b925c50)
1 parent 512ae89 commit 95ea7f2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

vector-stores/spring-ai-mariadb-store/src/main/java/org/springframework/ai/vectorstore/mariadb/MariaDBSchemaValidator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ public MariaDBSchemaValidator(JdbcTemplate jdbcTemplate) {
4545

4646
private boolean isTableExists(String schemaName, String tableName) {
4747
// schema and table are expected to be escaped
48-
String sql = String.format(
49-
"SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s",
50-
(schemaName == null) ? "SCHEMA()" : schemaName, tableName);
48+
String sql = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
5149
try {
5250
// Query for a single integer value, if it exists, table exists
53-
this.jdbcTemplate.queryForObject(sql, Integer.class);
51+
this.jdbcTemplate.queryForObject(sql, Integer.class, (schemaName == null) ? "SCHEMA()" : schemaName,
52+
tableName);
5453
return true;
5554
}
5655
catch (DataAccessException e) {

0 commit comments

Comments
 (0)