!114 feat:rdp优化,mssql迁移优化,term支持trzsz

* fix: 合并代码
* refactor: rdp优化,mssql迁移优化,term支持trzsz
This commit is contained in:
zongyangleo
2024-04-12 07:53:42 +00:00
committed by Coder慌
parent abc015aec0
commit 8998a21626
20 changed files with 551 additions and 360 deletions

View File

@@ -2,6 +2,7 @@ package mssql
import (
"fmt"
"io"
"mayfly-go/internal/db/dbm/dbi"
"mayfly-go/pkg/utils/anyx"
"mayfly-go/pkg/utils/collx"
@@ -194,6 +195,19 @@ func (ch *ColumnHelper) ToColumn(commonColumn *dbi.Column) {
} else {
commonColumn.DataType = dbi.ColumnDataType(ctype)
ch.FixColumn(commonColumn)
// 修复数据库迁移字段长度
dataType := string(commonColumn.DataType)
if collx.ArrayAnyMatches([]string{"nvarchar", "nchar"}, dataType) {
commonColumn.CharMaxLength = commonColumn.CharMaxLength * 2
}
if collx.ArrayAnyMatches([]string{"char"}, dataType) {
// char最大长度4000
if commonColumn.CharMaxLength >= 4000 {
commonColumn.DataType = "ntext"
commonColumn.CharMaxLength = 0
}
}
}
}
@@ -214,12 +228,29 @@ func (ch *ColumnHelper) FixColumn(column *dbi.Column) {
// 如果是nvarchar可视长度减半
column.CharMaxLength = column.CharMaxLength / 2
}
if collx.ArrayAnyMatches([]string{"char"}, dataType) {
// char最大长度4000
if column.CharMaxLength >= 4000 {
column.DataType = "ntext"
column.CharMaxLength = 0
}
}
}
type DumpHelper struct {
dbi.DefaultDumpHelper
}
// mssql 在insert语句前后不能识别begin和commit语句
func (dh *DumpHelper) BeforeInsert(writer io.Writer, tableName string) {
}
// mssql 在insert语句前后不能识别begin和commit语句
func (dh *DumpHelper) AfterInsert(writer io.Writer, tableName string, columns []dbi.Column) {
}
func (dh *DumpHelper) BeforeInsertSql(quoteSchema string, tableName string) string {
return fmt.Sprintf("set identity_insert %s.%s on ", quoteSchema, tableName)
}