mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
editing table works
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const { driverBase } = require('dbgate-tools');
|
||||
const Dumper = require('./Dumper');
|
||||
const { mysqlSplitterOptions } = require('dbgate-query-splitter/lib/options');
|
||||
const _cloneDeepWith = require('lodash/cloneDeepWith');
|
||||
|
||||
/** @type {import('dbgate-types').SqlDialect} */
|
||||
const dialect = {
|
||||
@@ -40,6 +41,35 @@ const driver = {
|
||||
usage == 'editor'
|
||||
? { ...mysqlSplitterOptions, ignoreComments: true, preventSingleLineSplit: true }
|
||||
: mysqlSplitterOptions,
|
||||
|
||||
createSaveChangeSetScript(changeSet, dbinfo, defaultCreator) {
|
||||
function removeConditionSource(cmd) {
|
||||
cmd.where = _cloneDeepWith(cmd.where, (expr) => {
|
||||
if (expr.exprType == 'column') {
|
||||
return {
|
||||
...expr,
|
||||
source: undefined,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const res = defaultCreator(changeSet, dbinfo);
|
||||
for (const cmd of res) {
|
||||
if (cmd.commandType == 'update') {
|
||||
cmd.alterTableUpdateSyntax = true;
|
||||
removeConditionSource(cmd);
|
||||
}
|
||||
if (cmd.commandType == 'delete') {
|
||||
const table = dbinfo?.tables?.find((x) => x.pureName == cmd?.from?.name?.pureName);
|
||||
if (table?.tableEngine != 'MergeTree') {
|
||||
cmd.alterTableDeleteSyntax = true;
|
||||
}
|
||||
removeConditionSource(cmd);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = driver;
|
||||
|
||||
Reference in New Issue
Block a user