Skip to content

Commit

Permalink
Cleanup code, pass err to scanFinish (go-rel#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
aligator committed May 27, 2022
1 parent e3cd023 commit 6ddb27e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion cursor.go
Expand Up @@ -81,7 +81,6 @@ func scanMulti(cur Cursor, keyField string, keyType reflect.Type, cols map[inter
}

if !found && fields != nil {
// TODO: why a panic and not just an easily catchable error?
panic("rel: primary key row does not exists")
}

Expand Down
5 changes: 2 additions & 3 deletions repository.go
Expand Up @@ -1030,8 +1030,7 @@ func (r repository) preload(cw contextWrapper, records slice, field string, quer
path = strings.Split(field, ".")
targets, table, keyField, keyType, ddata, loaded = r.mapPreloadTargets(records, path)
ids = r.targetIDs(targets)

inClauseLength = 999 // TODO: can this value come from the adapter, as it is dbms specific?
inClauseLength = 999
)

// Create separate queries if the amount of ids is more than inClauseLength.
Expand Down Expand Up @@ -1064,7 +1063,7 @@ func (r repository) preload(cw contextWrapper, records slice, field string, quer

scanFinish := r.instrumenter.Observe(cw.ctx, "rel-scan-multi", "scanning all records to multiple targets")
err = scanMulti(cur, keyField, keyType, targets)
scanFinish(nil)
scanFinish(err)
if err != nil {
return err
}
Expand Down

0 comments on commit 6ddb27e

Please sign in to comment.