mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 21:46:00 +00:00
refactor SQL
This commit is contained in:
@@ -35,7 +35,7 @@ const crypto = require('crypto');
|
|||||||
const loadModelTransform = require('../utility/loadModelTransform');
|
const loadModelTransform = require('../utility/loadModelTransform');
|
||||||
const exportDbModelSql = require('../utility/exportDbModelSql');
|
const exportDbModelSql = require('../utility/exportDbModelSql');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { callTextToSqlApi, callCompleteOnCursorApi } = require('../utility/authProxy');
|
const { callTextToSqlApi, callCompleteOnCursorApi, callRefactorSqlQueryApi } = require('../utility/authProxy');
|
||||||
|
|
||||||
const logger = getLogger('databaseConnections');
|
const logger = getLogger('databaseConnections');
|
||||||
|
|
||||||
@@ -593,4 +593,18 @@ module.exports = {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
refactorSqlQuery_meta: true,
|
||||||
|
async refactorSqlQuery({ conid, database, query, task, dialect }) {
|
||||||
|
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||||
|
const { structure } = existing || {};
|
||||||
|
if (!structure) return { errorMessage: 'No database structure' };
|
||||||
|
const res = await callRefactorSqlQueryApi(query, task, structure, dialect);
|
||||||
|
|
||||||
|
if (!res?.sql) {
|
||||||
|
return { errorMessage: 'No SQL generated' };
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ async function callCompleteOnCursorApi(cursorId, query, position, dialect) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function callRefactorSqlQueryApi(query, task, structure, dialect) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isAuthProxySupported,
|
isAuthProxySupported,
|
||||||
authProxyGetRedirectUrl,
|
authProxyGetRedirectUrl,
|
||||||
@@ -42,4 +46,5 @@ module.exports = {
|
|||||||
getAwsIamToken,
|
getAwsIamToken,
|
||||||
callTextToSqlApi,
|
callTextToSqlApi,
|
||||||
callCompleteOnCursorApi,
|
callCompleteOnCursorApi,
|
||||||
|
callRefactorSqlQueryApi,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -526,6 +526,16 @@
|
|||||||
editor.session.insert(editor.getCursorPosition(), text);
|
editor.session.insert(editor.getCursorPosition(), text);
|
||||||
domEditor?.getEditor()?.focus();
|
domEditor?.getEditor()?.focus();
|
||||||
}}
|
}}
|
||||||
|
getTextOrSelectedText={() => domEditor.getEditor().getSelectedText() || $editorValue}
|
||||||
|
onSetSelectedText={text => {
|
||||||
|
const editor = domEditor.getEditor();
|
||||||
|
if (editor.getSelectedText()) {
|
||||||
|
const range = editor.selection.getRange();
|
||||||
|
editor.session.replace(range, text);
|
||||||
|
} else {
|
||||||
|
editor.setValue(text);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</HorizontalSplitter>
|
</HorizontalSplitter>
|
||||||
|
|||||||
Reference in New Issue
Block a user