refactor(wip): fix deepsource analyze

This commit is contained in:
Cr 2021-09-06 14:05:19 +08:00
parent 0e9b2c27ea
commit d6866b6b2e
No known key found for this signature in database
GPG Key ID: E6C6812B87229952
3 changed files with 10 additions and 11 deletions

View File

@ -462,7 +462,7 @@ func (f *filterOrmDecorator) DoTxWithCtxAndOpts(ctx context.Context, opts *sql.T
TxStartTime: f.txStartTime,
TxName: getTxNameFromCtx(ctx),
f: func(c context.Context) []interface{} {
err := doTxTemplate(f, c, opts, task)
err := doTxTemplate(c, f, opts, task)
return []interface{}{err}
},
}

View File

@ -558,10 +558,10 @@ func (o *orm) DoTxWithOpts(opts *sql.TxOptions, task func(ctx context.Context, t
}
func (o *orm) DoTxWithCtxAndOpts(ctx context.Context, opts *sql.TxOptions, task func(ctx context.Context, txOrm TxOrmer) error) error {
return doTxTemplate(o, ctx, opts, task)
return doTxTemplate(ctx, o, opts, task)
}
func doTxTemplate(o TxBeginner, ctx context.Context, opts *sql.TxOptions,
func doTxTemplate(ctx context.Context, o TxBeginner, opts *sql.TxOptions,
task func(ctx context.Context, txOrm TxOrmer) error) error {
_txOrm, err := o.BeginWithCtxAndOpts(ctx, opts)
if err != nil {

View File

@ -129,7 +129,8 @@ func getCaller(skip int) string {
if cur == line {
flag = ">>"
}
code := fmt.Sprintf(" %s %5d: %s", flag, cur, strings.Replace(string(lines[o+i]), "\t", " ", -1))
ls := strings.Replace(string(lines[o+i]), "\t", " ", -1)
code := fmt.Sprintf(" %s %5d: %s", flag, cur, ls)
if code != "" {
codes = append(codes, code)
}
@ -883,10 +884,11 @@ func TestCustomField(t *testing.T) {
func TestExpr(t *testing.T) {
user := &User{}
qs := dORM.QueryTable(user)
qs = dORM.QueryTable((*User)(nil))
qs = dORM.QueryTable("User")
qs = dORM.QueryTable("user")
var qs QuerySeter
assert.NotPanics(t, func() { qs = dORM.QueryTable(user) })
assert.NotPanics(t, func() { qs = dORM.QueryTable((*User)(nil)) })
assert.NotPanics(t, func() { qs = dORM.QueryTable("User") })
assert.NotPanics(t, func() { qs = dORM.QueryTable("user") })
num, err := qs.Filter("UserName", "slene").Filter("user_name", "slene").Filter("profile__Age", 28).Count()
throwFail(t, err)
throwFail(t, AssertIs(num, 1))
@ -2859,12 +2861,10 @@ func TestCondition(t *testing.T) {
hasCycle(p.cond)
}
}
return
}
hasCycle(cond)
// cycleFlag was true,meaning use self as sub cond
throwFail(t, AssertIs(!cycleFlag, true))
return
}
func TestContextCanceled(t *testing.T) {
@ -2888,7 +2888,6 @@ func TestContextCanceled(t *testing.T) {
}
func TestDebugLog(t *testing.T) {
txCommitFn := func() {
o := NewOrm()
o.DoTx(func(ctx context.Context, txOrm TxOrmer) (txerr error) {