Skip to content

Commit

Permalink
1.修复Oracle无法使用的故障,使用Go-Ora替代OCI8
Browse files Browse the repository at this point in the history
2.修复原版Gorose打标错误导致Oracle完全无法输出的BUG
  • Loading branch information
tobycroft committed Oct 27, 2023
1 parent 6e5ed5b commit d1e6914
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- 修复了高并发下,where等参数的的脏数据问题(如果你在用原版,避免生产环境使用单db)
- 修复了Paginate不能用的问题,并且新增Paginator,让返回更加清晰
- 修复原版Count和GroupBy同时使用时会出现的Total(总条数)错误的问题
- 修复原版Oracle不可用问题,替换驱动使M1以后的ARM芯片可直连


## 实例文档(Wiki)
Expand Down Expand Up @@ -103,7 +104,7 @@ go get -u github.com/tobycroft/gorose-pro
- mysql : https://github.com/go-sql-driver/mysql
- sqlite3 : https://github.com/mattn/go-sqlite3
- postgres : https://github.com/lib/pq
- oracle : https://github.com/mattn/go-oci8
- oracle : https://github.com/mattn/go-ora
- mssql : https://github.com/denisenkom/go-mssqldb
- clickhouse : https://github.com/kshvakov/clickhouse

Expand Down
3 changes: 2 additions & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- Dirty Read under concurrency circumstances(this will be only and easily triggered by using *db mode)
- Paginate fixed, this function finally come back to life, new "Paginator" function make it much more easier to use
- Fix the row_count(Total in Paginator mode) when using GroupBy function
- Fix Oracle unable to connect & use problem, Fixed arm MacM1 chip's compatibility with Oracle

## Docs and Demos(Wiki)

Expand Down Expand Up @@ -95,7 +96,7 @@ go get -u github.com/tobycroft/gorose-pro
- mysql : https://github.com/go-sql-driver/mysql
- sqlite3 : https://github.com/mattn/go-sqlite3
- postgres : https://github.com/lib/pq
- oracle : https://github.com/mattn/go-oci8
- oracle : https://github.com/mattn/go-ora
- mssql : https://github.com/denisenkom/go-mssqldb
- clickhouse : https://github.com/kshvakov/clickhouse

Expand Down
8 changes: 8 additions & 0 deletions builder_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ func (FieldQuotesDefault) AddFieldQuotes(field string) string {
}
return field
}

func (FieldQuotesDefault) AddFieldQuotesOracle(field string) string {
reg := regexp.MustCompile(`^\w+$`)
if reg.MatchString(field) {
return fmt.Sprintf("\"%s\"", field)
}
return field
}
7 changes: 3 additions & 4 deletions builder_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
// DriverOracle ...
DriverOracle = "oci8"
DriverOracle = "oracle"
)

var (
Expand Down Expand Up @@ -43,7 +43,7 @@ func NewBuilderOracle(o IOrm) *BuilderOracle {

func init() {
var builder = &BuilderOracle{}
NewBuilderDriver().Register(DriverOracle, builder)
NewBuilderDriver().Register(DriverOracle, NewBuilderOracle(builder))
}

// Clone : a new obj
Expand Down Expand Up @@ -251,7 +251,6 @@ func (b *BuilderOracle) BuildWhere() (where string, err error) {
return If(where == "", "", " WHERE "+where).(string), err
}

// BuildDistinct ...
func (b *BuilderOracle) BuildDistinct() (dis string) {
return b.BuilderDefault.BuildDistinct()
}
Expand All @@ -263,7 +262,7 @@ func (b *BuilderOracle) BuildFields() string {

// BuildTable ...
func (b *BuilderOracle) BuildTable() string {
return b.BuilderDefault.BuildTable()
return b.AddFieldQuotesOracle(b.BuilderDefault.IOrm.GetTable())
}

// BuildGroup ...
Expand Down

0 comments on commit d1e6914

Please sign in to comment.