feat: support schema-qualified table completion in SQL editor

When typing `schema.` in the SQL editor for schema-aware databases
(PostgreSQL, GaussDB, etc.), auto-complete now suggests tables from
that schema. Falls back to schema lookup when the qualifier doesn't
match any table name.

Closes #239
This commit is contained in:
t8y2
2026-05-13 13:09:22 +08:00
parent 24b39bd853
commit 48785162e3
2 changed files with 25 additions and 4 deletions
+3 -2
View File
@@ -995,9 +995,10 @@ export const useConnectionStore = defineStore("connection", () => {
database: string,
filter = "",
limit?: number,
schema?: string,
): Promise<SqlCompletionTable[]> {
const normalizedFilter = filter.trim().toLowerCase();
const cacheKey = `${connectionId}:${database}:${normalizedFilter}:${limit ?? ""}`;
const cacheKey = `${connectionId}:${database}:${normalizedFilter}:${limit ?? ""}:${schema ?? ""}`;
if (completionTablesCache.value[cacheKey]) {
return completionTablesCache.value[cacheKey];
}
@@ -1005,7 +1006,7 @@ export const useConnectionStore = defineStore("connection", () => {
await ensureConnected(connectionId);
if (isSchemaAwareDatabase(connectionId)) {
const schemas = await api.listSchemas(connectionId, database);
const schemas = schema ? [schema] : await api.listSchemas(connectionId, database);
if (normalizedFilter || limit) {
const limitedTables: SqlCompletionTable[] = [];
for (const schema of schemas) {