feat(neo4j): expand node query properties into result columns
This commit is contained in:
1 parent
38a00c7cb7
commit
660071870b
12 files changed
+433
-29
No files matched your search
@@ -4,6 +4,8 @@ import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStor
|
||||
import { appendDebugLog, isDebugLoggingEnabled } from "@/lib/backend/debugLog";
|
||||
import { canReloadUnavailableDataTab, restoredDataTabReloadFilters } from "@/lib/table/tableDataRefresh";
|
||||
import { defaultViewForResult } from "@/lib/query/queryResultDefaultView";
|
||||
import { extractNeo4jNodeCells, projectNeo4jNodeResult } from "@/lib/neo4j/neo4jNodeResult";
|
||||
import { useNeo4jNodeTableResult } from "@/composables/useNeo4jNodeTableResult";
|
||||
import { queryResultMessages } from "@/lib/query/queryResultMessages";
|
||||
import { isQueryExecutionErrorResult } from "@/lib/query/queryResultError";
|
||||
import { hasQueryOutput as tabHasQueryOutput } from "@/lib/query/queryOutput";
|
||||
@@ -513,7 +515,7 @@ const tabularResults = computed(() => tabularResultItems(props.activeTab.results
|
||||
const allResultExportSheets = computed(() =>
|
||||
tabularResults.value.map((item) => ({
|
||||
sheetName: item.label || t("tabs.resultN", { n: item.n }),
|
||||
result: item.result,
|
||||
result: activeEffectiveDatabaseType.value === "neo4j" ? projectNeo4jNodeResult(item.result) : item.result,
|
||||
sql: item.index === props.activeTab.activeResultIndex ? queryResultExecutionSql(props.activeTab) : item.result.sourceStatement,
|
||||
})),
|
||||
);
|
||||
@@ -607,6 +609,26 @@ const resultRunFallbackLabel = (sequence: number) => t(resultTabNamingMode.value
|
||||
const activeResultGridCacheKey = computed(() => resultGridCacheKey(props.activeTab));
|
||||
const activeResultGridColumnWidthCacheKey = computed(() => resultGridColumnWidthCacheKey(props.activeTab));
|
||||
const activeResultGridInstanceKey = computed(() => resultGridInstanceKey(props.activeTab));
|
||||
const hasNeo4jNodes = computed(() => activeEffectiveDatabaseType.value === "neo4j" && !!props.activeTab.result?.neo4j_node_cells?.length);
|
||||
const neo4jNodeTable = useNeo4jNodeTableResult(
|
||||
computed(() => props.activeTab.result),
|
||||
activeResultGridInstanceKey,
|
||||
);
|
||||
const activeGridResult = computed(() => (hasNeo4jNodes.value ? neo4jNodeTable.result.value : props.activeTab.result));
|
||||
const activeGridSort = computed(() => (hasNeo4jNodes.value ? neo4jNodeTable.sort.value : undefined));
|
||||
|
||||
function sortQueryGrid(column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string, mode?: DataGridSortMode, effectiveOrderBy?: string) {
|
||||
if (hasNeo4jNodes.value) neo4jNodeTable.setSort(column, columnIndex, direction);
|
||||
else emit("sort", props.activeTab.id, column, columnIndex, direction, whereInput, mode, effectiveOrderBy);
|
||||
}
|
||||
|
||||
async function fetchGridResultForExport(onProgress?: (info: { rowsExported: number; totalRows: number | null }) => void) {
|
||||
const isNeo4j = activeEffectiveDatabaseType.value === "neo4j";
|
||||
const result = await queryStore.fetchTabResultForExport(props.activeTab.id, onProgress);
|
||||
if (!result || !isNeo4j) return result;
|
||||
extractNeo4jNodeCells(result);
|
||||
return projectNeo4jNodeResult(result);
|
||||
}
|
||||
const activeResultSql = computed(() => resultSqlForGrid(props.activeTab));
|
||||
const activeResultExportSql = computed(() => queryResultExecutionSql(props.activeTab));
|
||||
const activeStatementExecutionMarkers = computed(() =>
|
||||
@@ -2422,21 +2444,22 @@ defineExpose({
|
||||
:pending-state-key="activeResultGridInstanceKey"
|
||||
:view-generation="activeTab.resultViewGeneration"
|
||||
class="flex-1 min-h-0"
|
||||
:result="activeTab.result"
|
||||
:sort-column="activeTab.resultSortColumn"
|
||||
:sort-column-index="activeTab.resultSortColumnIndex"
|
||||
:sort-direction="activeTab.resultSortDirection"
|
||||
:sort-mode="activeTab.resultSortMode"
|
||||
:result="activeGridResult!"
|
||||
:sort-column="hasNeo4jNodes ? activeGridSort?.column : activeTab.resultSortColumn"
|
||||
:sort-column-index="hasNeo4jNodes ? activeGridSort?.columnIndex : activeTab.resultSortColumnIndex"
|
||||
:sort-direction="hasNeo4jNodes ? activeGridSort?.direction : activeTab.resultSortDirection"
|
||||
:sort-mode="hasNeo4jNodes ? 'local' : activeTab.resultSortMode"
|
||||
:database-sort-enabled="!hasNeo4jNodes"
|
||||
:initial-order-by-input="activeTab.orderByInput"
|
||||
:sql="activeResultSql"
|
||||
:export-sql="activeResultExportSql"
|
||||
:loading="activeResultIsLoading"
|
||||
:editable="!!activeTab.queryAnalysis || !!mongoQueryResultSaveHandler"
|
||||
:source-columns="activeTab.querySourceColumns"
|
||||
:joined-write-targets="activeTab.queryWriteTargets"
|
||||
:readonly-column-indexes="groupedQueryReadonlyColumnIndexes(activeTab)"
|
||||
:result-column-comments="activeTab.resultColumnComments"
|
||||
:query-display-source-columns="activeTab.queryDisplaySourceColumns"
|
||||
:editable="!hasNeo4jNodes && (!!activeTab.queryAnalysis || !!mongoQueryResultSaveHandler)"
|
||||
:source-columns="hasNeo4jNodes ? undefined : activeTab.querySourceColumns"
|
||||
:joined-write-targets="hasNeo4jNodes ? undefined : activeTab.queryWriteTargets"
|
||||
:readonly-column-indexes="hasNeo4jNodes ? undefined : groupedQueryReadonlyColumnIndexes(activeTab)"
|
||||
:result-column-comments="hasNeo4jNodes ? undefined : activeTab.resultColumnComments"
|
||||
:query-display-source-columns="hasNeo4jNodes ? undefined : activeTab.queryDisplaySourceColumns"
|
||||
:custom-save-handler="mongoQueryResultSaveHandler"
|
||||
:mongo-update-target="mongoQueryResultSaveHandler && activeTab.result.mongo_copy_documents?.length === activeTab.result.rows.length ? activeTab.mongoEditTarget : undefined"
|
||||
:query-editability-reason="activeTab.queryEditabilityReason"
|
||||
@@ -2451,7 +2474,7 @@ defineExpose({
|
||||
:connection-id="activeResultConnectionId"
|
||||
:database="activeResultDatabase"
|
||||
:schema="activeResultSchema"
|
||||
:table-meta="activeTab.tableMeta"
|
||||
:table-meta="hasNeo4jNodes ? undefined : activeTab.tableMeta"
|
||||
:table-info-tab="activeTab.tableInfoTab"
|
||||
:page-offset="activeTab.resultPageOffset"
|
||||
:page-limit="activeTab.resultPageLimit"
|
||||
@@ -2464,18 +2487,20 @@ defineExpose({
|
||||
:total-row-count-loading="activeTab.resultTotalRowCountLoading"
|
||||
:page-jump-progress="activeTab.resultPageJumpProgress"
|
||||
:on-execute-sql="async (sql: string) => emit('executeSql', activeTab.id, sql)"
|
||||
:full-export-result="(onProgress?: (info: { rowsExported: number; totalRows: number | null }) => void) => queryStore.fetchTabResultForExport(activeTab.id, onProgress)"
|
||||
:full-export-result="fetchGridResultForExport"
|
||||
:query-result-export-request="
|
||||
(options: {
|
||||
exportId: string;
|
||||
filePath: string;
|
||||
format: 'csv' | 'xlsx' | 'json' | 'txt' | 'sql';
|
||||
includeSqlSheet?: boolean;
|
||||
exportTableName?: string;
|
||||
exportColumnTypes?: Array<string | null | undefined>;
|
||||
exportColumnExtras?: Array<string | null | undefined>;
|
||||
insertMode?: SqlInsertMode;
|
||||
}) => queryStore.buildQueryResultExportRequest(activeTab.id, options)
|
||||
hasNeo4jNodes
|
||||
? undefined
|
||||
: (options: {
|
||||
exportId: string;
|
||||
filePath: string;
|
||||
format: 'csv' | 'xlsx' | 'json' | 'txt' | 'sql';
|
||||
includeSqlSheet?: boolean;
|
||||
exportTableName?: string;
|
||||
exportColumnTypes?: Array<string | null | undefined>;
|
||||
exportColumnExtras?: Array<string | null | undefined>;
|
||||
insertMode?: SqlInsertMode;
|
||||
}) => queryStore.buildQueryResultExportRequest(activeTab.id, options)
|
||||
"
|
||||
:all-export-results="allResultExportSheets"
|
||||
:export-file-base-name="activeQueryResultExportBaseName"
|
||||
@@ -2487,7 +2512,7 @@ defineExpose({
|
||||
@local-column-filters-change="(filters: Record<string, string[]>) => queryStore.updateDataGridLocalColumnFilters(activeTab.id, filters)"
|
||||
@reload="(sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number, intent?: DataGridReloadIntent) => emit('reload', activeTab.id, sql, searchText, whereInput, orderBy, limit, offset, intent)"
|
||||
@paginate="(offset: number, limit: number, whereInput?: string, orderBy?: string, appendResult?: boolean) => emit('paginate', activeTab.id, offset, limit, whereInput, orderBy, appendResult)"
|
||||
@sort="(column: string, columnIndex: number, direction: 'asc' | 'desc' | null, whereInput?: string, mode?: DataGridSortMode, effectiveOrderBy?: string) => emit('sort', activeTab.id, column, columnIndex, direction, whereInput, mode, effectiveOrderBy)"
|
||||
@sort="sortQueryGrid"
|
||||
@change-query-timeout="(connectionId: string) => emit('openConnectionSettings', connectionId, 'advanced')"
|
||||
>
|
||||
<template #result-toolbar-leading="{ compact }">
|
||||
|
||||
Reference in new issue
Block a user