This commit is contained in:
Lunny Xiao 2023-06-30 13:47:10 +08:00
parent ff568c74f2
commit 701f5e6f68
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 10 additions and 5 deletions

View File

@ -474,7 +474,8 @@ func (db *mssql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
cols := make(map[string]*schemas.Column)
colSeq := make([]string, 0)
for rows.Next() {
var name, ctype, vdefault, collation string
var name, ctype, vdefault string
var collation *string
var maxLen, precision, scale int64
var nullable, isPK, defaultIsNull, isIncrement bool
err = rows.Scan(&name, &ctype, &maxLen, &precision, &scale, &nullable, &defaultIsNull, &vdefault, &isPK, &isIncrement, &collation)
@ -499,7 +500,9 @@ func (db *mssql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
} else {
col.Length = maxLen
}
col.Collation = collation
if collation != nil {
col.Collation = *collation
}
switch ct {
case "DATETIMEOFFSET":
col.SQLType = schemas.SQLType{Name: schemas.TimeStampz, DefaultLength: 0, DefaultLength2: 0}

View File

@ -426,9 +426,9 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
col := new(schemas.Column)
col.Indexes = make(map[string]int)
var columnName, nullableStr, colType, colKey, extra, comment, collation string
var columnName, nullableStr, colType, colKey, extra, comment string
var alreadyQuoted, isUnsigned bool
var colDefault, maxLength *string
var colDefault, maxLength, collation *string
err = rows.Scan(&columnName, &nullableStr, &colDefault, &colType, &colKey, &extra, &comment, &maxLength, &alreadyQuoted, &collation)
if err != nil {
return nil, nil, err
@ -445,7 +445,9 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
} else {
col.DefaultIsEmpty = true
}
col.Collation = collation
if collation != nil {
col.Collation = *collation
}
fields := strings.Fields(colType)
if len(fields) == 2 && fields[1] == "unsigned" {