feat(query): move SQL editability analysis to Rust
This commit is contained in:
1 parent
c736fe372a
commit
cb3e1d6e9f
12 files changed
+685
-7
No files matched your search
@@ -87,6 +87,7 @@ export const executeInTransaction = forward("executeInTransaction");
|
||||
export const cancelQuery = forward("cancelQuery");
|
||||
export const closeQuerySession = forward("closeQuerySession");
|
||||
export const analyzeSqlReferences = forward("analyzeSqlReferences");
|
||||
export const analyzeEditableQueryEditability = forward("analyzeEditableQueryEditability");
|
||||
|
||||
// AI
|
||||
export const aiComplete = forward("aiComplete");
|
||||
|
||||
@@ -49,6 +49,7 @@ import type {
|
||||
ExportProgress,
|
||||
XlsxCellValue,
|
||||
} from "./tauri";
|
||||
import type { QueryEditability } from "@/lib/sqlAnalysis";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
@@ -404,6 +405,10 @@ export async function analyzeSqlReferences(sql: string, dialect?: string): Promi
|
||||
return post("/api/query/analyze-sql-references", { sql, dialect });
|
||||
}
|
||||
|
||||
export async function analyzeEditableQueryEditability(sql: string): Promise<QueryEditability> {
|
||||
return post("/api/query/analyze-editability", { sql });
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// AI
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -21,6 +21,7 @@ import type {
|
||||
SavedSqlLibrary,
|
||||
} from "@/types/database";
|
||||
import type { AiConfig } from "@/stores/settingsStore";
|
||||
import type { QueryEditability } from "@/lib/sqlAnalysis";
|
||||
|
||||
export interface AgentDriverInfo {
|
||||
db_type: string;
|
||||
@@ -312,6 +313,10 @@ export async function analyzeSqlReferences(sql: string, dialect?: string): Promi
|
||||
return invoke("analyze_sql_references", { sql, dialect });
|
||||
}
|
||||
|
||||
export async function analyzeEditableQueryEditability(sql: string): Promise<QueryEditability> {
|
||||
return invoke("analyze_editable_query_editability", { sql });
|
||||
}
|
||||
|
||||
export async function listIndexes(
|
||||
connectionId: string,
|
||||
database: string,
|
||||
|
||||
@@ -6,12 +6,7 @@ import { orderPinnedFirst } from "@/lib/pinnedItems";
|
||||
import { canCancelQueryExecution } from "@/lib/queryExecutionState";
|
||||
import { closeAllTabsState, closeOtherTabsState } from "@/lib/tabCloseActions";
|
||||
import { buildExplainSql, parseExplainResult } from "@/lib/explainPlan";
|
||||
import {
|
||||
allEditableColumnsWriteable,
|
||||
allPrimaryKeysPresent,
|
||||
analyzeEditableQueryEditability,
|
||||
sourceColumnsForResult,
|
||||
} from "@/lib/sqlAnalysis";
|
||||
import { allEditableColumnsWriteable, allPrimaryKeysPresent, sourceColumnsForResult } from "@/lib/sqlAnalysis";
|
||||
import { restoreOpenTabsState, serializeOpenTabs } from "@/lib/openTabsPersistence";
|
||||
import {
|
||||
mongoCountToQueryResult,
|
||||
@@ -373,7 +368,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const editability = analyzeEditableQueryEditability(sql);
|
||||
const editability = await api.analyzeEditableQueryEditability(sql);
|
||||
if (!editability.editable) {
|
||||
tab.queryAnalysis = undefined;
|
||||
tab.querySourceColumns = undefined;
|
||||
|
||||
Reference in new issue
Block a user