mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 17:36:01 +00:00
correct export from read-only connection
This commit is contained in:
@@ -168,12 +168,24 @@
|
||||
.sort(${JSON.stringify(buildMongoSort($$props) || {})})`;
|
||||
}
|
||||
|
||||
export function exportGrid() {
|
||||
function getExportQueryJson() {
|
||||
return {
|
||||
collection: pureName,
|
||||
condition: buildGridMongoCondition($$props) || {},
|
||||
sort: buildMongoSort($$props) || {},
|
||||
};
|
||||
}
|
||||
|
||||
export async function exportGrid() {
|
||||
const coninfo = await getConnectionInfo({ conid });
|
||||
const initialValues: any = {};
|
||||
initialValues.sourceStorageType = 'query';
|
||||
initialValues.sourceConnectionId = conid;
|
||||
initialValues.sourceDatabaseName = database;
|
||||
initialValues.sourceSql = getExportQuery();
|
||||
initialValues.sourceQuery = coninfo.isReadOnly
|
||||
? JSON.stringify(getExportQueryJson(), undefined, 2)
|
||||
: getExportQuery();
|
||||
initialValues.sourceQueryType = coninfo.isReadOnly ? 'json' : 'native';
|
||||
initialValues.sourceList = [pureName];
|
||||
initialValues[`columns_${pureName}`] = display.getExportColumnMap();
|
||||
showModal(ImportExportModal, { initialValues });
|
||||
@@ -204,7 +216,8 @@
|
||||
functionName: 'queryReader',
|
||||
props: {
|
||||
connection: extractShellConnection(coninfo, database),
|
||||
sql: getExportQuery(),
|
||||
queryType: coninfo.isReadOnly ? 'json' : 'native',
|
||||
query: coninfo.isReadOnly ? getExportQueryJson() : getExportQuery(),
|
||||
},
|
||||
},
|
||||
fmt,
|
||||
|
||||
@@ -129,12 +129,17 @@
|
||||
// $: console.log('GRIDER', grider);
|
||||
// $: if (onChangeGrider) onChangeGrider(grider);
|
||||
|
||||
export function exportGrid() {
|
||||
export async function exportGrid() {
|
||||
const coninfo = await getConnectionInfo({ conid });
|
||||
|
||||
const initialValues: any = {};
|
||||
initialValues.sourceStorageType = 'query';
|
||||
initialValues.sourceConnectionId = conid;
|
||||
initialValues.sourceDatabaseName = database;
|
||||
initialValues.sourceSql = display.getExportQuery();
|
||||
initialValues.sourceQuery = coninfo.isReadOnly
|
||||
? JSON.stringify(display.getExportQueryJson(), undefined, 2)
|
||||
: display.getExportQuery();
|
||||
initialValues.sourceQueryType = coninfo.isReadOnly ? 'json' : 'native';
|
||||
initialValues.sourceList = display.baseTableOrSimilar ? [display.baseTableOrSimilar.pureName] : [];
|
||||
initialValues[`columns_${pureName}`] = display.getExportColumnMap();
|
||||
showModal(ImportExportModal, { initialValues });
|
||||
@@ -189,7 +194,8 @@
|
||||
functionName: 'queryReader',
|
||||
props: {
|
||||
connection: extractShellConnection(coninfo, database),
|
||||
sql: display.getExportQuery(),
|
||||
queryType: coninfo.isReadOnly ? 'json' : 'native',
|
||||
query: coninfo.isReadOnly ? display.getExportQueryJson() : display.getExportQuery(),
|
||||
},
|
||||
},
|
||||
fmt,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
import FormSchemaSelect from './FormSchemaSelect.svelte';
|
||||
import FormTablesSelect from './FormTablesSelect.svelte';
|
||||
import { findEngineDriver } from 'dbgate-tools';
|
||||
import AceEditor from '../query/AceEditor.svelte';
|
||||
|
||||
export let direction;
|
||||
export let storageTypeField;
|
||||
@@ -137,12 +138,19 @@
|
||||
{#if storageType == 'query'}
|
||||
<div class="label">Query</div>
|
||||
<div class="sqlwrap">
|
||||
<SqlEditor
|
||||
value={$values.sourceSql}
|
||||
on:input={e => setFieldValue('sourceSql', e.detail)}
|
||||
{engine}
|
||||
focusOnCreate
|
||||
/>
|
||||
{#if $values.sourceQueryType == 'json'}
|
||||
<AceEditor
|
||||
value={$values.sourceQuery}
|
||||
on:input={e => setFieldValue('sourceQuery', e.detail)}
|
||||
mode="json"
|
||||
/>
|
||||
{:else}
|
||||
<SqlEditor
|
||||
value={$values.sourceQuery}
|
||||
on:input={e => setFieldValue('sourceQuery', e.detail)}
|
||||
{engine}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -78,7 +78,8 @@ function getSourceExpr(extensions, sourceName, values, sourceConnection, sourceD
|
||||
{
|
||||
connection: sourceConnection,
|
||||
...extractDriverApiParameters(values, 'source', sourceDriver),
|
||||
sql: values.sourceSql,
|
||||
queryType: values.sourceQueryType,
|
||||
query: values.sourceQueryType == 'json' ? JSON.parse(values.sourceQuery) : values.sourceQuery,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user