feat: add support for 南大通用(GBASE) GBase8s database

This commit is contained in:
zhangyunfei 2025-07-17 06:50:46 +00:00
parent f50aacd38b
commit e930396f66
4 changed files with 1107 additions and 0 deletions

1089
dialects/gbase8s.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -798,6 +798,22 @@ func (engine *Engine) dumpTables(ctx context.Context, tables []*schemas.Table, w
return err return err
} }
} }
} else if sess.engine.dialect.URI().DBType == schemas.GBASE8S {
stp.Name = strings.Replace(stp.Name, "SQLT_", "", 1)
if stp.IsTime() && len(s.String) == 20 { // "2025-06-10T07:55:31Z"
t, err := time.Parse(time.RFC3339, s.String)
if err != nil {
return fmt.Errorf("failed to parse time %s: %v", s.String, err)
}
r := t.Format("2006-01-02 15:04:05")
if _, err = io.WriteString(w, "'"+r+"'"); err != nil {
return err
}
} else {
if _, err = io.WriteString(w, "'"+strings.ReplaceAll(s.String, "'", "''")+"'"); 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

View File

@ -23,6 +23,7 @@ const (
MSSQL DBType = "mssql" MSSQL DBType = "mssql"
ORACLE DBType = "oracle" ORACLE DBType = "oracle"
DAMENG DBType = "dameng" DAMENG DBType = "dameng"
GBASE8S DBType = "gbase8s"
) )
// SQLType represents SQL types // SQLType represents SQL types

View File

@ -196,6 +196,7 @@ func (session *Session) SyncWithOptions(opts SyncOptions, beans ...interface{})
} }
} else if col.Comment != oriCol.Comment { } else if col.Comment != oriCol.Comment {
if engine.dialect.URI().DBType == schemas.POSTGRES || if engine.dialect.URI().DBType == schemas.POSTGRES ||
engine.dialect.URI().DBType == schemas.GBASE8S ||
engine.dialect.URI().DBType == schemas.MYSQL { engine.dialect.URI().DBType == schemas.MYSQL {
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col)) _, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
} }