mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 23:36:01 +00:00
call complete on cursor
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 } = require('../utility/authProxy');
|
const { callTextToSqlApi, callCompleteOnCursorApi } = require('../utility/authProxy');
|
||||||
|
|
||||||
const logger = getLogger('databaseConnections');
|
const logger = getLogger('databaseConnections');
|
||||||
|
|
||||||
@@ -573,7 +573,21 @@ module.exports = {
|
|||||||
|
|
||||||
const res = await callTextToSqlApi(text, structure, dialect);
|
const res = await callTextToSqlApi(text, structure, dialect);
|
||||||
|
|
||||||
if (!res.sql) {
|
if (!res?.sql) {
|
||||||
|
return { errorMessage: 'No SQL generated' };
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
|
completeOnCursor_meta: true,
|
||||||
|
async completeOnCursor({ conid, database, text, dialect, line }) {
|
||||||
|
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 callCompleteOnCursorApi(text, structure, dialect, line);
|
||||||
|
|
||||||
|
if (!res?.sql) {
|
||||||
return { errorMessage: 'No SQL generated' };
|
return { errorMessage: 'No SQL generated' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ async function callTextToSqlApi(text, structure, dialect) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function callCompleteOnCursorApi(cursorId, query, position, dialect) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isAuthProxySupported,
|
isAuthProxySupported,
|
||||||
authProxyGetRedirectUrl,
|
authProxyGetRedirectUrl,
|
||||||
@@ -37,4 +41,5 @@ module.exports = {
|
|||||||
supportsAwsIam,
|
supportsAwsIam,
|
||||||
getAwsIamToken,
|
getAwsIamToken,
|
||||||
callTextToSqlApi,
|
callTextToSqlApi,
|
||||||
|
callCompleteOnCursorApi,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -519,6 +519,8 @@
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
isAiAssistantVisible = false;
|
isAiAssistantVisible = false;
|
||||||
}}
|
}}
|
||||||
|
text={$editorValue}
|
||||||
|
getLine={() => domEditor.getEditor().getSelectionRange().start.row}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</HorizontalSplitter>
|
</HorizontalSplitter>
|
||||||
|
|||||||
Reference in New Issue
Block a user