mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 12:01:29 +00:00
check qs is nil before get forContext
This commit is contained in:
parent
e56d1b718f
commit
d5cf1050db
@ -764,7 +764,7 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
|
|||||||
d.ins.ReplaceMarks(&query)
|
d.ins.ReplaceMarks(&query)
|
||||||
var err error
|
var err error
|
||||||
var res sql.Result
|
var res sql.Result
|
||||||
if qs.forContext {
|
if qs != nil && qs.forContext {
|
||||||
res, err = q.ExecContext(qs.ctx, query, values...)
|
res, err = q.ExecContext(qs.ctx, query, values...)
|
||||||
} else {
|
} else {
|
||||||
res, err = q.Exec(query, values...)
|
res, err = q.Exec(query, values...)
|
||||||
@ -862,7 +862,7 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
|
|||||||
|
|
||||||
d.ins.ReplaceMarks(&query)
|
d.ins.ReplaceMarks(&query)
|
||||||
var res sql.Result
|
var res sql.Result
|
||||||
if qs.forContext {
|
if qs != nil && qs.forContext {
|
||||||
res, err = q.ExecContext(qs.ctx, query, args...)
|
res, err = q.ExecContext(qs.ctx, query, args...)
|
||||||
} else {
|
} else {
|
||||||
res, err = q.Exec(query, args...)
|
res, err = q.Exec(query, args...)
|
||||||
@ -990,7 +990,7 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
|
|||||||
|
|
||||||
var rs *sql.Rows
|
var rs *sql.Rows
|
||||||
var err error
|
var err error
|
||||||
if qs.forContext {
|
if qs != nil && qs.forContext {
|
||||||
rs, err = q.QueryContext(qs.ctx, query, args...)
|
rs, err = q.QueryContext(qs.ctx, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -1130,7 +1130,7 @@ func (d *dbBase) Count(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condition
|
|||||||
d.ins.ReplaceMarks(&query)
|
d.ins.ReplaceMarks(&query)
|
||||||
|
|
||||||
var row *sql.Row
|
var row *sql.Row
|
||||||
if qs.forContext {
|
if qs != nil && qs.forContext {
|
||||||
row = q.QueryRowContext(qs.ctx, query, args...)
|
row = q.QueryRowContext(qs.ctx, query, args...)
|
||||||
} else {
|
} else {
|
||||||
row = q.QueryRow(query, args...)
|
row = q.QueryRow(query, args...)
|
||||||
|
Loading…
Reference in New Issue
Block a user