fix 5255: Check the rows.Err() if rows.Next() is false
This commit is contained in:
parent
480e816ab6
commit
bc63be6d13
@ -2,6 +2,7 @@
|
|||||||
- [httplib: fix unstable unit test which use the httplib.org](https://github.com/beego/beego/pull/5232)
|
- [httplib: fix unstable unit test which use the httplib.org](https://github.com/beego/beego/pull/5232)
|
||||||
- [remove adapter package](https://github.com/beego/beego/pull/5239)
|
- [remove adapter package](https://github.com/beego/beego/pull/5239)
|
||||||
- [feat: add write-delete cache mode](https://github.com/beego/beego/pull/5242)
|
- [feat: add write-delete cache mode](https://github.com/beego/beego/pull/5242)
|
||||||
|
- [fix 5255: Check the rows.Err() if rows.Next() is false](https://github.com/beego/beego/pull/5256)
|
||||||
|
|
||||||
## ORM refactoring
|
## ORM refactoring
|
||||||
- [introducing internal/models pkg](https://github.com/beego/beego/pull/5238)
|
- [introducing internal/models pkg](https://github.com/beego/beego/pull/5238)
|
||||||
|
|||||||
@ -884,6 +884,10 @@ func (d *dbBase) DeleteBatch(ctx context.Context, q dbQuerier, qs *querySet, mi
|
|||||||
cnt++
|
cnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rs.Err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
if cnt == 0 {
|
if cnt == 0 {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
@ -1123,6 +1127,10 @@ func (d *dbBase) ReadBatch(ctx context.Context, q dbQuerier, qs *querySet, mi *m
|
|||||||
cnt++
|
cnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rs.Err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
if !one {
|
if !one {
|
||||||
if cnt > 0 {
|
if cnt > 0 {
|
||||||
ind.Set(slice)
|
ind.Set(slice)
|
||||||
@ -1769,6 +1777,10 @@ func (d *dbBase) ReadValues(ctx context.Context, q dbQuerier, qs *querySet, mi *
|
|||||||
cnt++
|
cnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rs.Err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
switch v := container.(type) {
|
switch v := container.(type) {
|
||||||
case *[]Params:
|
case *[]Params:
|
||||||
*v = maps
|
*v = maps
|
||||||
@ -1847,7 +1859,7 @@ func (d *dbBase) GetTables(db dbQuerier) (map[string]bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tables, nil
|
return tables, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetColumns get all cloumns in table.
|
// GetColumns get all cloumns in table.
|
||||||
@ -1874,7 +1886,7 @@ func (d *dbBase) GetColumns(ctx context.Context, db dbQuerier, table string) (ma
|
|||||||
columns[name] = [3]string{name, typ, null}
|
columns[name] = [3]string{name, typ, null}
|
||||||
}
|
}
|
||||||
|
|
||||||
return columns, nil
|
return columns, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// not implement.
|
// not implement.
|
||||||
|
|||||||
@ -136,7 +136,7 @@ func (d *dbBaseSqlite) GetColumns(ctx context.Context, db dbQuerier, table strin
|
|||||||
columns[name.String] = [3]string{name.String, typ.String, null.String}
|
columns[name.String] = [3]string{name.String, typ.String, null.String}
|
||||||
}
|
}
|
||||||
|
|
||||||
return columns, nil
|
return columns, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// get show Columns sql in sqlite.
|
// get show Columns sql in sqlite.
|
||||||
|
|||||||
@ -22,12 +22,12 @@ import (
|
|||||||
// don't forget to call next(...) inside your Filter
|
// don't forget to call next(...) inside your Filter
|
||||||
type FilterChain func(next Filter) Filter
|
type FilterChain func(next Filter) Filter
|
||||||
|
|
||||||
// Filter's behavior is a little big strange.
|
// Filter behavior is a little big strange.
|
||||||
// it's only be called when users call methods of Ormer
|
// it's only be called when users call methods of Ormer
|
||||||
// return value is an array. it's a little bit hard to understand,
|
// return value is an array. it's a little bit hard to understand,
|
||||||
// for example, the Ormer's Read method only return error
|
// for example, the Ormer's Read method only return error
|
||||||
// so the filter processing this method should return an array whose first element is error
|
// so the filter processing this method should return an array whose first element is error
|
||||||
// and, Ormer's ReadOrCreateWithCtx return three values, so the Filter's result should contains three values
|
// and, Ormer's ReadOrCreateWithCtx return three values, so the Filter's result should contain three values
|
||||||
type Filter func(ctx context.Context, inv *Invocation) []interface{}
|
type Filter func(ctx context.Context, inv *Invocation) []interface{}
|
||||||
|
|
||||||
var globalFilterChains = make([]FilterChain, 0, 4)
|
var globalFilterChains = make([]FilterChain, 0, 4)
|
||||||
|
|||||||
@ -447,7 +447,7 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// query data rows and map to container
|
// QueryRows query data rows and map to container
|
||||||
func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
|
func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
|
||||||
var (
|
var (
|
||||||
refs = make([]interface{}, 0, len(containers))
|
refs = make([]interface{}, 0, len(containers))
|
||||||
@ -504,7 +504,6 @@ func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
|
|||||||
sInd := sInds[0]
|
sInd := sInds[0]
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
|
||||||
if structMode {
|
if structMode {
|
||||||
columns, err := rows.Columns()
|
columns, err := rows.Columns()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -597,16 +596,18 @@ func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
|
|||||||
sInd = reflect.Append(sInd, ind)
|
sInd = reflect.Append(sInd, ind)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if err := rows.Scan(refs...); err != nil {
|
if err = rows.Scan(refs...); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
o.loopSetRefs(refs, sInds, &nInds, eTyps, cnt == 0)
|
o.loopSetRefs(refs, sInds, &nInds, eTyps, cnt == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt++
|
cnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
if cnt > 0 {
|
if cnt > 0 {
|
||||||
if structMode {
|
if structMode {
|
||||||
sInds[0].Set(sInd)
|
sInds[0].Set(sInd)
|
||||||
@ -734,6 +735,10 @@ func (o *rawSet) readValues(container interface{}, needCols []string) (int64, er
|
|||||||
cnt++
|
cnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rs.Err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
switch v := container.(type) {
|
switch v := container.(type) {
|
||||||
case *[]Params:
|
case *[]Params:
|
||||||
*v = maps
|
*v = maps
|
||||||
@ -849,6 +854,9 @@ func (o *rawSet) queryRowsTo(container interface{}, keyCol, valueCol string) (in
|
|||||||
cnt++
|
cnt++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rs.Err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
if typ == 1 {
|
if typ == 1 {
|
||||||
v, _ := container.(*Params)
|
v, _ := container.(*Params)
|
||||||
*v = maps
|
*v = maps
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user