mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 11:26:00 +00:00
refactor SQL
This commit is contained in:
@@ -35,7 +35,7 @@ const crypto = require('crypto');
|
||||
const loadModelTransform = require('../utility/loadModelTransform');
|
||||
const exportDbModelSql = require('../utility/exportDbModelSql');
|
||||
const axios = require('axios');
|
||||
const { callTextToSqlApi, callCompleteOnCursorApi } = require('../utility/authProxy');
|
||||
const { callTextToSqlApi, callCompleteOnCursorApi, callRefactorSqlQueryApi } = require('../utility/authProxy');
|
||||
|
||||
const logger = getLogger('databaseConnections');
|
||||
|
||||
@@ -593,4 +593,18 @@ module.exports = {
|
||||
|
||||
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;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user