Skip to content

Commit 2ec5ccd

Browse files
authored
fix(schemaActions): preserve query settings when insert snippet (#1615)
1 parent 3e4a04b commit 2ec5ccd

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

src/containers/Tenant/utils/schemaActions.ts

+21-30
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {changeUserInput} from '../../../store/reducers/executeQuery';
66
import type {GetTableSchemaDataParams} from '../../../store/reducers/tableSchemaData';
77
import {TENANT_PAGES_IDS, TENANT_QUERY_TABS_ID} from '../../../store/reducers/tenant/constants';
88
import {setQueryTab, setTenantPage} from '../../../store/reducers/tenant/tenant';
9-
import type {QueryMode, QuerySettings} from '../../../types/store/query';
9+
import type {QuerySettings} from '../../../types/store/query';
1010
import createToast from '../../../utils/createToast';
1111
import {transformPath} from '../ObjectSummary/transformPath';
1212
import type {SchemaData} from '../Schema/SchemaViewer/types';
@@ -57,18 +57,9 @@ const bindActions = (
5757
dispatch: AppDispatch,
5858
additionalEffects: ActionsAdditionalEffects,
5959
) => {
60-
const {
61-
setActivePath,
62-
updateQueryExecutionSettings,
63-
showCreateDirectoryDialog,
64-
getTableSchemaDataPromise,
65-
} = additionalEffects;
66-
67-
const inputQuery = (tmpl: TemplateFn, mode?: QueryMode) => () => {
68-
if (mode) {
69-
updateQueryExecutionSettings({queryMode: mode});
70-
}
60+
const {setActivePath, showCreateDirectoryDialog, getTableSchemaDataPromise} = additionalEffects;
7161

62+
const inputQuery = (tmpl: TemplateFn) => () => {
7263
const pathType = nodeTableTypeToPathType[params.type];
7364
const withTableData = [selectQueryTemplate, upsertQueryTemplate].includes(tmpl);
7465

@@ -96,26 +87,26 @@ const bindActions = (
9687
showCreateDirectoryDialog(params.path);
9788
}
9889
: undefined,
99-
createTable: inputQuery(createTableTemplate, 'script'),
100-
createColumnTable: inputQuery(createColumnTableTemplate, 'script'),
101-
createAsyncReplication: inputQuery(createAsyncReplicationTemplate, 'script'),
102-
alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate, 'script'),
103-
dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate, 'script'),
104-
alterTable: inputQuery(alterTableTemplate, 'script'),
105-
dropTable: inputQuery(dropTableTemplate, 'script'),
90+
createTable: inputQuery(createTableTemplate),
91+
createColumnTable: inputQuery(createColumnTableTemplate),
92+
createAsyncReplication: inputQuery(createAsyncReplicationTemplate),
93+
alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate),
94+
dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate),
95+
alterTable: inputQuery(alterTableTemplate),
96+
dropTable: inputQuery(dropTableTemplate),
10697
selectQuery: inputQuery(selectQueryTemplate),
10798
upsertQuery: inputQuery(upsertQueryTemplate),
108-
createExternalTable: inputQuery(createExternalTableTemplate, 'script'),
109-
dropExternalTable: inputQuery(dropExternalTableTemplate, 'script'),
110-
selectQueryFromExternalTable: inputQuery(selectQueryTemplate, 'query'),
111-
createTopic: inputQuery(createTopicTemplate, 'script'),
112-
alterTopic: inputQuery(alterTopicTemplate, 'script'),
113-
dropTopic: inputQuery(dropTopicTemplate, 'script'),
114-
createView: inputQuery(createViewTemplate, 'script'),
115-
dropView: inputQuery(dropViewTemplate, 'script'),
116-
dropIndex: inputQuery(dropTableIndex, 'script'),
117-
addTableIndex: inputQuery(addTableIndex, 'script'),
118-
createCdcStream: inputQuery(createCdcStreamTemplate, 'script'),
99+
createExternalTable: inputQuery(createExternalTableTemplate),
100+
dropExternalTable: inputQuery(dropExternalTableTemplate),
101+
selectQueryFromExternalTable: inputQuery(selectQueryTemplate),
102+
createTopic: inputQuery(createTopicTemplate),
103+
alterTopic: inputQuery(alterTopicTemplate),
104+
dropTopic: inputQuery(dropTopicTemplate),
105+
createView: inputQuery(createViewTemplate),
106+
dropView: inputQuery(dropViewTemplate),
107+
dropIndex: inputQuery(dropTableIndex),
108+
addTableIndex: inputQuery(addTableIndex),
109+
createCdcStream: inputQuery(createCdcStreamTemplate),
119110
copyPath: () => {
120111
try {
121112
copy(params.relativePath);

0 commit comments

Comments
 (0)