mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 16:24:33 +00:00
fix: filter SQL completion tables
This commit is contained in:
+8
-2
@@ -172,8 +172,14 @@ export async function listSchemas(connectionId: string, database: string): Promi
|
||||
return get(`/api/schema/schemas?${qs({ connection_id: connectionId, database })}`);
|
||||
}
|
||||
|
||||
export async function listTables(connectionId: string, database: string, schema: string): Promise<TableInfo[]> {
|
||||
return get(`/api/schema/tables?${qs({ connection_id: connectionId, database, schema })}`);
|
||||
export async function listTables(
|
||||
connectionId: string,
|
||||
database: string,
|
||||
schema: string,
|
||||
filter?: string,
|
||||
limit?: number,
|
||||
): Promise<TableInfo[]> {
|
||||
return get(`/api/schema/tables?${qs({ connection_id: connectionId, database, schema, filter, limit })}`);
|
||||
}
|
||||
|
||||
export async function listObjects(connectionId: string, database: string, schema: string): Promise<ObjectInfo[]> {
|
||||
|
||||
@@ -133,6 +133,7 @@ const SQL_KEYWORDS = [
|
||||
|
||||
const TABLE_TRIGGER_KEYWORDS = new Set(["from", "join", "update", "into", "table", "describe", "explain", "apply"]);
|
||||
const JOIN_MODIFIERS = new Set(["left", "right", "inner", "outer", "cross", "full", "natural"]);
|
||||
const MAX_TABLE_COMPLETION_ITEMS = 200;
|
||||
|
||||
export interface SqlCompletionTable {
|
||||
name: string;
|
||||
@@ -463,6 +464,7 @@ function unquoteIdentifier(value: string): string {
|
||||
function buildTableItems(prefix: string, tables: SqlCompletionTable[]): SqlCompletionItem[] {
|
||||
return tables
|
||||
.filter((table) => matchesPrefix(table.name, prefix))
|
||||
.slice(0, MAX_TABLE_COMPLETION_ITEMS)
|
||||
.map((table) => ({
|
||||
label: table.name,
|
||||
type: "table" as const,
|
||||
|
||||
+8
-2
@@ -138,8 +138,14 @@ export async function deleteSchemaCachePrefix(prefix: string): Promise<void> {
|
||||
return invoke("delete_schema_cache_prefix", { prefix });
|
||||
}
|
||||
|
||||
export async function listTables(connectionId: string, database: string, schema: string): Promise<TableInfo[]> {
|
||||
return invoke("list_tables", { connectionId, database, schema });
|
||||
export async function listTables(
|
||||
connectionId: string,
|
||||
database: string,
|
||||
schema: string,
|
||||
filter?: string,
|
||||
limit?: number,
|
||||
): Promise<TableInfo[]> {
|
||||
return invoke("list_tables", { connectionId, database, schema, filter, limit });
|
||||
}
|
||||
|
||||
export async function listObjects(connectionId: string, database: string, schema: string): Promise<ObjectInfo[]> {
|
||||
|
||||
Reference in New Issue
Block a user