mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 12:03:58 +00:00
fix:fix: removeu duplicate method, simplify changeColumnComment
This commit is contained in:
@@ -161,32 +161,15 @@ class MsSqlDumper extends SqlDumper {
|
|||||||
this.endCommand();
|
this.endCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('dbgate-types').TableInfo} table
|
|
||||||
*/
|
|
||||||
createColumnComment(table) {
|
|
||||||
const { schemaName, pureName, objectComment } = table;
|
|
||||||
if (!objectComment) return;
|
|
||||||
|
|
||||||
this.put('&>^exec sp_addextendedproperty&n');
|
|
||||||
this.put(`@value = N'%s',&n`, objectComment);
|
|
||||||
this.put("@level0type = N'SCHEMA', @level0name = '%s',&n", schemaName);
|
|
||||||
this.put("@level1type = N'TABLE', @level1name = '%s'&n&<", pureName);
|
|
||||||
this.endCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('dbgate-types').ColumnInfo} oldcol
|
* @param {import('dbgate-types').ColumnInfo} oldcol
|
||||||
* @param {import('dbgate-types').ColumnInfo} newcol
|
* @param {import('dbgate-types').ColumnInfo} newcol
|
||||||
*/
|
*/
|
||||||
changeColumnComment(oldcol, newcol) {
|
changeColumnComment(oldcol, newcol) {
|
||||||
if (oldcol.columnComment == newcol.columnComment) return;
|
if (oldcol.columnComment === newcol.columnComment) return;
|
||||||
if (oldcol.columnComment && !newcol.columnComment) {
|
|
||||||
this.dropColumnComment(newcol);
|
if (oldcol.columnComment) this.dropColumnComment(newcol);
|
||||||
} else {
|
if (newcol.columnComment) this.createColumnComment(newcol);
|
||||||
this.dropColumnComment(newcol);
|
|
||||||
this.createColumnComment(newcol);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,7 +194,7 @@ class MsSqlDumper extends SqlDumper {
|
|||||||
if (!columnComment) return;
|
if (!columnComment) return;
|
||||||
|
|
||||||
this.put('&>^exec sp_addextendedproperty&n');
|
this.put('&>^exec sp_addextendedproperty&n');
|
||||||
this.put("@name = N'MS_Description',");
|
this.put("@name = N'MS_Description', ");
|
||||||
this.put(`@value = N'%s',&n`, columnComment);
|
this.put(`@value = N'%s',&n`, columnComment);
|
||||||
this.put("@level0type = N'SCHEMA', @level0name = '%s',&n", schemaName);
|
this.put("@level0type = N'SCHEMA', @level0name = '%s',&n", schemaName);
|
||||||
this.put("@level1type = N'TABLE', @level1name = '%s',&n", pureName);
|
this.put("@level1type = N'TABLE', @level1name = '%s',&n", pureName);
|
||||||
@@ -219,6 +202,17 @@ class MsSqlDumper extends SqlDumper {
|
|||||||
this.endCommand();
|
this.endCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('dbgate-types').TableInfo} table
|
||||||
|
*/
|
||||||
|
createTable(table) {
|
||||||
|
super.createTable(table);
|
||||||
|
|
||||||
|
for (const column of table.columns || []) {
|
||||||
|
this.createColumnComment(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
changeColumn(oldcol, newcol, constraints) {
|
changeColumn(oldcol, newcol, constraints) {
|
||||||
if (testEqualColumns(oldcol, newcol, false, false, { ignoreComments: true })) {
|
if (testEqualColumns(oldcol, newcol, false, false, { ignoreComments: true })) {
|
||||||
this.dropDefault(oldcol);
|
this.dropDefault(oldcol);
|
||||||
|
|||||||
Reference in New Issue
Block a user