Skip to content

Commit a4efd7e

Browse files
fix(nl2sql): modify the primary key processing logic to support list … (#2395)
fix(nl2sql): modify the primary key processing logic to support list and string types
1 parent 9f0b1c0 commit a4efd7e

File tree

1 file changed

+11
-3
lines changed
  • spring-ai-alibaba-nl2sql/spring-ai-alibaba-nl2sql-chat/src/main/java/com/alibaba/cloud/ai/service/base

1 file changed

+11
-3
lines changed

spring-ai-alibaba-nl2sql/spring-ai-alibaba-nl2sql-chat/src/main/java/com/alibaba/cloud/ai/service/base/BaseSchemaService.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,17 @@ protected List<TableDTO> buildTableListFromDocuments(List<Document> documents) {
277277
dto.setName((String) meta.get("name"));
278278
dto.setDescription((String) meta.get("description"));
279279
if (meta.containsKey("primaryKey")) {
280-
String primaryKey = (String) meta.get("primaryKey");
281-
if (StringUtils.isNotBlank(primaryKey)) {
282-
dto.setPrimaryKeys(List.of(primaryKey));
280+
Object primaryKeyObj = meta.get("primaryKey");
281+
if (primaryKeyObj instanceof List) {
282+
@SuppressWarnings("unchecked")
283+
List<String> primaryKeys = (List<String>) primaryKeyObj;
284+
dto.setPrimaryKeys(primaryKeys);
285+
}
286+
else if (primaryKeyObj instanceof String) {
287+
String primaryKey = (String) primaryKeyObj;
288+
if (StringUtils.isNotBlank(primaryKey)) {
289+
dto.setPrimaryKeys(List.of(primaryKey));
290+
}
283291
}
284292
}
285293
tableList.add(dto);

0 commit comments

Comments
 (0)