feat: Support GBase8s Database (#2517)
## Background Currently, XORM does not yet support the [GBase 8s database by Nanda General Data Technology]. GBase 8s is a widely used domestic database in China, commonly adopted by enterprises and government systems as a backend storage solution. ## Summary of This Contribution • Added support for the gbase8s driver • Implemented a basic database dialect: GBase8sDialect ## Usage Instructions ```go import _ "gitee.com/GBase8s/go-gci"" engine, err := xorm.NewEngine("gbase8s", "gbase8s://username:pwd@ip:port/dbname?param=xxx") Co-authored-by: zhangyunfei <zhangyunfei@gbase.cn> Reviewed-on: https://gitea.com/xorm/xorm/pulls/2517 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: maktub <maktub@noreply.gitea.com> Co-committed-by: maktub <maktub@noreply.gitea.com>
This commit is contained in:
parent
f50aacd38b
commit
89d1238248
|
@ -50,6 +50,9 @@ Drivers for Go's sql package which currently support database/sql includes:
|
||||||
* MsSql
|
* MsSql
|
||||||
- [github.com/microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb)
|
- [github.com/microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb)
|
||||||
|
|
||||||
|
* GBase8s
|
||||||
|
- [https://gitee.com/GBase8s/go-gci](https://gitee.com/GBase8s/go-gci)
|
||||||
|
|
||||||
* Oracle
|
* Oracle
|
||||||
- [github.com/godror/godror](https://github.com/godror/godror) (experiment)
|
- [github.com/godror/godror](https://github.com/godror/godror) (experiment)
|
||||||
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (experiment)
|
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (experiment)
|
||||||
|
|
|
@ -49,6 +49,9 @@ v1.0.0 相对于 v0.8.2 有以下不兼容的变更:
|
||||||
* MsSql
|
* MsSql
|
||||||
- [github.com/microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb)
|
- [github.com/microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb)
|
||||||
|
|
||||||
|
* GBase8s
|
||||||
|
- [https://gitee.com/GBase8s/go-gci](https://gitee.com/GBase8s/go-gci)
|
||||||
|
|
||||||
* Oracle
|
* Oracle
|
||||||
- [github.com/godror/godror](https://github.com/godror/godror) (试验性支持)
|
- [github.com/godror/godror](https://github.com/godror/godror) (试验性支持)
|
||||||
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (试验性支持)
|
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (试验性支持)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
16
engine.go
16
engine.go
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
1
sync.go
1
sync.go
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue