fix
parent
91013ab523
commit
51af81d925
|
@ -24,8 +24,8 @@ func (s *SqlBuilder[T]) Conditions(cond string, args ...interface{}) {
|
|||
} else {
|
||||
cond, args = dealInCondition(cond, args)
|
||||
}
|
||||
s.Opts.conditions = append(s.Opts.conditions, cond)
|
||||
s.Opts.args = append(s.Opts.args, args...)
|
||||
s.Opts.Conditions = append(s.Opts.Conditions, cond)
|
||||
s.Opts.Args = append(s.Opts.Args, args...)
|
||||
s.buildCondition(util.ConditionPlaceholder, cond)
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,8 @@ func (s *SqlBuilder[T]) InsertConditions(symbol string, cond string, args ...int
|
|||
} else {
|
||||
cond, args = dealInCondition(cond, args)
|
||||
}
|
||||
s.Opts.conditions = append(s.Opts.conditions, cond)
|
||||
s.Opts.args = append(s.Opts.args, args...)
|
||||
s.Opts.Conditions = append(s.Opts.Conditions, cond)
|
||||
s.Opts.Args = append(s.Opts.Args, args...)
|
||||
s.buildCondition(symbol, cond)
|
||||
}
|
||||
|
||||
|
|
12
db/db.go
12
db/db.go
|
@ -25,8 +25,8 @@ type SqlBuilder[T tydb.QOneRowRst | tytaos.QOneRowRst | tyoracle.QOneRowRst | in
|
|||
type Options struct {
|
||||
util.Page
|
||||
selects []string
|
||||
conditions []string
|
||||
args []interface{} // condition的参数
|
||||
Conditions []string
|
||||
Args []interface{} // condition的参数
|
||||
groups []string
|
||||
orders []string
|
||||
partitions []string // tdengine专用
|
||||
|
@ -55,12 +55,12 @@ func (s *SqlBuilder[T]) SetDriver(driver string) {
|
|||
|
||||
func (s *SqlBuilder[T]) FindBySql(data interface{}) error {
|
||||
sqls := s.buildSql()
|
||||
return s.Connector.QueryEx(sqls, data, s.Opts.args...)
|
||||
return s.Connector.QueryEx(sqls, data, s.Opts.Args...)
|
||||
}
|
||||
|
||||
func (s *SqlBuilder[T]) FindOneBySql(data interface{}) error {
|
||||
sqls := s.buildSql()
|
||||
err, _ := s.Connector.QueryRow(sqls, data, s.Opts.args...)
|
||||
err, _ := s.Connector.QueryRow(sqls, data, s.Opts.Args...)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,11 @@ func (s *SqlBuilder[T]) PaginateBySql(data interface{}, page util.Page) error {
|
|||
sqls := s.buildSql()
|
||||
count_sql := s.buildCountSql(sqls)
|
||||
paginage_sql := s.buildPaginateSql(sqls)
|
||||
err, _ = s.Connector.QueryRow(count_sql, &total, s.Opts.args...)
|
||||
err, _ = s.Connector.QueryRow(count_sql, &total, s.Opts.Args...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.Opts.Page.SetTotal(total)
|
||||
err = s.Connector.QueryEx(paginage_sql, data, s.Opts.args...)
|
||||
err = s.Connector.QueryEx(paginage_sql, data, s.Opts.Args...)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue