fix(completion): scoped table lookup, preserve casing, lower Oracle table-function boost
* fix: improve schema-qualified SQL completion * fix(completion): preserve casing in completion table cache key and relaxed filter --------- Co-authored-by: zipg <4047349+zipg@users.noreply.github.com> Co-authored-by: t8y2 <1156263951@qq.com>
This commit is contained in:
5 files changed
+51
-9
No files matched your search
@@ -3916,9 +3916,14 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
}
|
||||
|
||||
async function listCompletionTables(connectionId: string, database: string, filter = "", limit?: number, schema?: string): Promise<SqlCompletionTable[]> {
|
||||
const normalizedFilter = filter.trim().toLowerCase();
|
||||
const relaxedFilter = relaxedCompletionTableFilter(normalizedFilter);
|
||||
const cacheKey = `${connectionId}:${database}:${normalizedFilter}:${limit ?? ""}:${schema ?? ""}`;
|
||||
const trimmedFilter = filter.trim();
|
||||
const normalizedFilter = trimmedFilter.toLowerCase();
|
||||
// Remote queries (Dameng/Oracle) are case-sensitive, so the cache key must
|
||||
// preserve original casing — otherwise "TEST" and "test" collide and the
|
||||
// second lookup returns the first's stale results. Local lookups below stay
|
||||
// case-insensitive because tableMatchScore normalizes internally.
|
||||
const relaxedFilter = relaxedCompletionTableFilter(trimmedFilter);
|
||||
const cacheKey = `${connectionId}:${database}:${trimmedFilter}:${limit ?? ""}:${schema ?? ""}`;
|
||||
if (completionTablesCache.value[cacheKey]) {
|
||||
return completionTablesCache.value[cacheKey];
|
||||
}
|
||||
@@ -3932,10 +3937,10 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
if (normalizedFilter || limit) {
|
||||
let results: SqlCompletionTable[] = [];
|
||||
try {
|
||||
results = await listCompletionAssistantTables(connectionId, database, normalizedFilter, limit, schema);
|
||||
results = await listCompletionAssistantTables(connectionId, database, trimmedFilter, limit, schema);
|
||||
} catch {
|
||||
if (schema) {
|
||||
const tables = await api.listTables(connectionId, database, schema, normalizedFilter, limit);
|
||||
const tables = await api.listTables(connectionId, database, schema, trimmedFilter, limit);
|
||||
results = tables.map((table) => ({
|
||||
name: table.name,
|
||||
schema,
|
||||
@@ -3983,7 +3988,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
return completionTablesCache.value[cacheKey];
|
||||
}
|
||||
|
||||
let tables = await api.listTables(connectionId, database, database, normalizedFilter, limit);
|
||||
let tables = await api.listTables(connectionId, database, database, trimmedFilter, limit);
|
||||
if (tables.length === 0 && relaxedFilter) {
|
||||
tables = await api.listTables(connectionId, database, database, relaxedFilter, expandedCompletionLimit(limit));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user