fix(structure): load dynamic data type options
This commit is contained in:
1 parent
5ffac129e0
commit
cdfe576024
24 files changed
+380
-3
No files matched your search
@@ -15,6 +15,7 @@ public final class AgentProtocol {
|
||||
public static final String METHOD_LIST_SCHEMAS = "list_schemas";
|
||||
public static final String METHOD_LIST_TABLES = "list_tables";
|
||||
public static final String METHOD_LIST_OBJECTS = "list_objects";
|
||||
public static final String METHOD_LIST_DATA_TYPES = "list_data_types";
|
||||
public static final String METHOD_COMPLETION_ASSISTANT_SEARCH_V1 = "completion_assistant_search_v1";
|
||||
public static final String METHOD_GET_OBJECT_SOURCE = "get_object_source";
|
||||
public static final String METHOD_GET_TABLE_DDL = "get_table_ddl";
|
||||
@@ -85,6 +86,7 @@ public final class AgentProtocol {
|
||||
METHOD_LIST_SCHEMAS,
|
||||
METHOD_LIST_TABLES,
|
||||
METHOD_LIST_OBJECTS,
|
||||
METHOD_LIST_DATA_TYPES,
|
||||
METHOD_COMPLETION_ASSISTANT_SEARCH_V1,
|
||||
METHOD_GET_OBJECT_SOURCE,
|
||||
METHOD_GET_TABLE_DDL,
|
||||
|
||||
@@ -60,6 +60,11 @@ public abstract class ConfiguredJdbcAgent extends AbstractJdbcAgent {
|
||||
return StandardJdbcMetadata.INSTANCE.listObjects(listTables(schema), schema);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listDataTypes() {
|
||||
return StandardJdbcMetadata.INSTANCE.listDataTypes(requireConnection());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionAssistantResponse completionAssistantSearch(CompletionAssistantRequest request) {
|
||||
return StandardJdbcMetadata.INSTANCE.completionAssistantSearch(requireConnection(), profile, configuredDatabase, request);
|
||||
|
||||
@@ -35,6 +35,10 @@ public interface DatabaseAgent {
|
||||
return result;
|
||||
}
|
||||
|
||||
default List<String> listDataTypes() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
default CompletionAssistantResponse completionAssistantSearch(CompletionAssistantRequest request) {
|
||||
throw new UnsupportedOperationException("Completion assistant search is not supported by this agent");
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ public final class JsonRpcServer {
|
||||
switchCatalog(params);
|
||||
return agent.listObjects(params.get("schema").getAsString());
|
||||
}
|
||||
if (AgentProtocol.METHOD_LIST_DATA_TYPES.equals(method)) {
|
||||
switchCatalog(params);
|
||||
return agent.listDataTypes();
|
||||
}
|
||||
if (AgentProtocol.METHOD_COMPLETION_ASSISTANT_SEARCH_V1.equals(method)) {
|
||||
switchCatalog(params);
|
||||
return agent.completionAssistantSearch(gson.fromJson(params, CompletionAssistantRequest.class));
|
||||
|
||||
@@ -90,6 +90,26 @@ public final class StandardJdbcMetadata {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> listDataTypes(Connection conn) {
|
||||
return unchecked(() -> {
|
||||
Set<String> seen = new LinkedHashSet<>();
|
||||
List<String> names = new ArrayList<>();
|
||||
try (ResultSet rs = conn.getMetaData().getTypeInfo()) {
|
||||
while (rs.next()) {
|
||||
String name = rs.getString("TYPE_NAME");
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String trimmed = name.trim();
|
||||
if (seen.add(trimmed.toLowerCase(Locale.ROOT))) {
|
||||
names.add(trimmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
});
|
||||
}
|
||||
|
||||
public CompletionAssistantResponse completionAssistantSearch(
|
||||
Connection conn,
|
||||
JdbcAgentProfile profile,
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"list_schemas",
|
||||
"list_tables",
|
||||
"list_objects",
|
||||
"list_data_types",
|
||||
"completion_assistant_search_v1",
|
||||
"get_object_source",
|
||||
"get_table_ddl",
|
||||
|
||||
Reference in new issue
Block a user