1 parent
fc6c5d4aa6
commit
55d611141b
9 files changed
+195
-10
No files matched your search
@@ -1569,7 +1569,7 @@ defineExpose({ focusSearch, refreshData, refreshQueryEditorCompletionCache, hand
|
||||
: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"
|
||||
:allow-insert-rows="activeTab.queryAnalysis?.allowInsert !== false && activeTab.queryAnalysis?.allowInsertDelete !== false"
|
||||
:allow-insert-rows="activeTab.queryAnalysis?.allowInsert ?? activeTab.queryAnalysis?.allowInsertDelete !== false"
|
||||
:allow-delete-rows="activeTab.queryAnalysis?.allowInsertDelete !== false"
|
||||
context="results"
|
||||
:auto-transpose-single-row="settingsStore.editorSettings.dataGridAutoTransposeSingleRow"
|
||||
|
||||
@@ -160,7 +160,7 @@ export function analyzeEditableQueryEditability(sql: string): QueryEditability {
|
||||
tableAlias: source.alias,
|
||||
selectStar,
|
||||
columns,
|
||||
...(distinct ? { distinct: true, allowInsertDelete: false } : {}),
|
||||
...(distinct ? { distinct: true, allowInsert: false, allowInsertDelete: false } : {}),
|
||||
};
|
||||
if (sources.length > 1) {
|
||||
analysis.sources = sources;
|
||||
|
||||
@@ -35,7 +35,7 @@ import { nextRedisCommandDb } from "@/lib/redis/redisCommandSession";
|
||||
import { isRedisMutatingCommand } from "@/lib/redis/redisCommandTable";
|
||||
import { usesAgentCursorForQuery } from "@/lib/database/databaseDriverManifest";
|
||||
import { supportsClearableQuerySchema } from "@/lib/database/databaseFeatureSupport";
|
||||
import { canUseKeylessRowPredicate, DBX_ROWID_COLUMN, editablePrimaryKeys, usesSyntheticRowIdKey } from "@/lib/table/tableEditing";
|
||||
import { canInsertTableRows, canUseKeylessRowPredicate, DBX_ROWID_COLUMN, editablePrimaryKeys, usesSyntheticRowIdKey } from "@/lib/table/tableEditing";
|
||||
import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/table/tableDataExport";
|
||||
import { tableMetaForDataTab } from "@/lib/table/tableDataTabMeta";
|
||||
import { dataTabExecutionDatabase } from "@/lib/table/dataTabExecutionDatabase";
|
||||
@@ -3380,6 +3380,16 @@ export const useQueryStore = defineStore("query", () => {
|
||||
writeSchema?: string;
|
||||
};
|
||||
|
||||
function canInsertIntoEditableQuerySource(tab: QueryTab, databaseType: DatabaseType | undefined, loaded: LoadedEditableSource, sourceColumns: readonly (string | undefined)[] | undefined): boolean {
|
||||
if (!canInsertTableRows(databaseType) || !sourceColumns?.length || !sourceColumns.every(Boolean)) return false;
|
||||
const knownTableType =
|
||||
loaded.tableMeta.tableType ??
|
||||
useConnectionStore()
|
||||
.lookupLocalCompletionTables(tab.connectionId!, loaded.tableMeta.database ?? tab.database, loaded.tableMeta.tableName, 20, loaded.tableMeta.schema, loaded.tableMeta.catalog)
|
||||
.find((table) => table.name.toLowerCase() === loaded.tableMeta.tableName.toLowerCase())?.type;
|
||||
return !knownTableType?.toUpperCase().includes("VIEW");
|
||||
}
|
||||
|
||||
interface EditableQueryExecutionPreparation {
|
||||
sql: string;
|
||||
metadataSql: string;
|
||||
@@ -3699,7 +3709,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
}
|
||||
|
||||
return {
|
||||
queryAnalysis: metadataAnalysis,
|
||||
queryAnalysis: metadataAnalysis.distinct && canInsertIntoEditableQuerySource(tab, dbType as DatabaseType, loaded, sourceColumns) ? { ...metadataAnalysis, allowInsert: true } : metadataAnalysis,
|
||||
querySourceColumns: sourceColumns,
|
||||
queryEditabilityReason: undefined,
|
||||
tableMeta: primaryKeys === loaded.tableMeta.primaryKeys ? loaded.tableMeta : { ...loaded.tableMeta, primaryKeys },
|
||||
@@ -3727,6 +3737,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
const target = candidates[0]!;
|
||||
const queryAnalysis = {
|
||||
...target.analysis,
|
||||
...(target.analysis.distinct && canInsertIntoEditableQuerySource(tab, dbType as DatabaseType, target, target.sourceColumns) ? { allowInsert: true } : {}),
|
||||
allowInsertDelete: false,
|
||||
multiSource: true,
|
||||
};
|
||||
|
||||
@@ -1247,6 +1247,7 @@ export interface QueryTab {
|
||||
multiSource?: boolean;
|
||||
allowInsert?: boolean;
|
||||
allowInsertDelete?: boolean;
|
||||
distinct?: boolean;
|
||||
sources?: {
|
||||
key: string;
|
||||
catalog?: string;
|
||||
|
||||
Reference in new issue
Block a user