mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user