From d8653ccf8f1b368dea7a7692d8c8e430291035d1 Mon Sep 17 00:00:00 2001 From: lj-wsdj <1134294381@qq.com> Date: Wed, 21 Aug 2024 14:24:38 +0800 Subject: [PATCH] fix --- conf/conf.go | 1 + db/add_sql.go | 11 ++++++----- go.mod | 2 +- go.sum | 2 ++ main_test.go | 28 ++++++++++++---------------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/conf/conf.go b/conf/conf.go index 54a79e4..ebc03da 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -5,6 +5,7 @@ import ( "git.botann.com/tinycs/boomerang/tyconf/ini" "git.botann.com/tinycs/boomerang/tyoracle" "git.botann.com/tinycs/boomerang/tyoracle/basesql" + _ "github.com/godror/godror" ) var APP AppConf diff --git a/db/add_sql.go b/db/add_sql.go index 8ec659b..2c6e4eb 100644 --- a/db/add_sql.go +++ b/db/add_sql.go @@ -33,11 +33,12 @@ func (s *SqlBuilder[T]) InsertConditions(symbol string, cond string, args ...int if strings.HasPrefix(cond, " and") { cond = strings.Join(strings.Split(cond, " and")[1:], " and ") } - if s.Driver == util.DriverOracle { - cond, args = dealOralceInCondition(cond, args) - } else { - cond, args = dealInCondition(cond, args) - } + // if s.Driver == util.DriverOracle { + // cond, args = dealOralceInCondition(cond, args) + // } else { + // cond, args = dealInCondition(cond, args) + // } + cond, args = dealInCondition(cond, args) s.Opts.Conditions = append(s.Opts.Conditions, cond) s.Opts.Args = append(s.Opts.Args, args...) s.buildCondition(symbol, cond) diff --git a/go.mod b/go.mod index 353a5ef..eb5ec69 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module git.botann.com/lijun/sql-builder go 1.21.5 -require git.botann.com/tinycs/boomerang v1.4.7 +require git.botann.com/tinycs/boomerang v1.4.12 require ( github.com/go-logfmt/logfmt v0.6.0 // indirect diff --git a/go.sum b/go.sum index 32b8892..ab8d1d4 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ git.botann.com/tinycs/boomerang v1.4.7 h1:O3M38Y1i+Kl/U9ii4U124r0MKibVQcZ+a9IjOTpSOu4= git.botann.com/tinycs/boomerang v1.4.7/go.mod h1:JA5Fu88ZdYmkWMXVLRe/bZ3GE/iWxPUUvi1hSsg3cOQ= +git.botann.com/tinycs/boomerang v1.4.12 h1:IcvLkzHFnVkJRNsMaDEPs8ixaRHpLw6IdhKNyZdHZY4= +git.botann.com/tinycs/boomerang v1.4.12/go.mod h1:YTA0bw60BnajniDSvTyVt6vYtBKLEf70eG/gKfSDz80= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/UNO-SOFT/zlog v0.8.1 h1:TEFkGJHtUfTRgMkLZiAjLSHALjwSBdw6/zByMC5GJt4= diff --git a/main_test.go b/main_test.go index 3b2192d..99cd60b 100644 --- a/main_test.go +++ b/main_test.go @@ -50,28 +50,24 @@ func (p *Page) SetPageSize(pageSize int) { func TestOracle(t *testing.T) { var err error - type Employye struct { - EmployeeId int `json:"employee_id"` - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Email string `json:"email"` - Rn int + type Area struct { + Autoseq int `json:"autoseq"` + Name string `json:"name"` + Id string `json:"id"` + AreaDn string `json:"area_dn"` + Rn int `json:"rn"` } - var data []Employye + var data []Area + var ids = []int{86986, 86987} sqlb := OracleSqlBuilder() - err = sqlb.SetSchema("HR") - if err != nil { - fmt.Println(err) - } - var ids = []int{100, 101, 102} - sqls := `select employee_id,first_name,last_name,email from employees where 1=1 @c1 @c2` + sqls := `select autoseq,name,id,area_dn from tareas where del = 0 @c1 @c2` sqlb.Sql = sqls - sqlb.InsertConditions("@c1", "employee_id in (:in)", ids) - sqlb.InsertConditions("@c2", "first_name = :first_name and last_name = :last_name", "Steven", "King") + sqlb.InsertConditions("@c1", "area_dn like ?", "level1=1,level2=85226,level3=86918,level4=86919,level5=86986%") + sqlb.InsertConditions("@c2", "autoseq in (?)", ids) page := Page{PageIndex: 1, PageSize: 10} err = sqlb.PaginateBySql(&data, &page) page.Data = &data - fmt.Println(err, page.Data) + fmt.Println(err, page) } func TestMysql(t *testing.T) {