This commit is contained in:
Lunny Xiao 2021-08-07 11:31:58 +08:00
parent 4f6dd437c4
commit 25b3513489
2 changed files with 12 additions and 3 deletions

View File

@ -836,8 +836,8 @@ func (db *dameng) GetColumns(queryer core.Queryer, ctx context.Context, tableNam
col.Indexes = make(map[string]int) col.Indexes = make(map[string]int)
var colDefault dmClobScanner var colDefault dmClobScanner
var colName, nullable, dataType, dataPrecision, dataScale, comment sql.NullString var colName, nullable, dataType, dataPrecision, comment sql.NullString
var dataLen sql.NullInt64 var dataScale, dataLen sql.NullInt64
err = rows.Scan(&colName, &colDefault, &dataType, &dataLen, &dataPrecision, err = rows.Scan(&colName, &colDefault, &dataType, &dataLen, &dataPrecision,
&dataScale, &nullable, &comment) &dataScale, &nullable, &comment)
@ -923,7 +923,11 @@ func (db *dameng) GetColumns(queryer core.Queryer, ctx context.Context, tableNam
return nil, nil, fmt.Errorf("unknown colType %v %v", dataType.String, col.SQLType) return nil, nil, fmt.Errorf("unknown colType %v %v", dataType.String, col.SQLType)
} }
col.Length = int(dataLen.Int64) if col.SQLType.Name == "TIMESTAMP" {
col.Length = int(dataScale.Int64)
} else {
col.Length = int(dataLen.Int64)
}
if col.SQLType.IsText() || col.SQLType.IsTime() { if col.SQLType.IsText() || col.SQLType.IsTime() {
if !col.DefaultIsEmpty { if !col.DefaultIsEmpty {

View File

@ -588,6 +588,11 @@ func (engine *Engine) dumpTables(ctx context.Context, tables []*schemas.Table, w
if _, err = io.WriteString(w, formatBool(s.String, dstDialect)); err != nil { if _, err = io.WriteString(w, formatBool(s.String, dstDialect)); err != nil {
return err return err
} }
} else if sess.engine.dialect.URI().DBType == schemas.DAMENG && stp.IsTime() && len(s.String) == 25 {
r := strings.Replace(s.String[:19], "T", " ", -1)
if _, err = io.WriteString(w, "'"+r+"'"); err != nil {
return err
}
} else { } else {
if _, err = io.WriteString(w, "'"+strings.ReplaceAll(s.String, "'", "''")+"'"); err != nil { if _, err = io.WriteString(w, "'"+strings.ReplaceAll(s.String, "'", "''")+"'"); err != nil {
return err return err