From 6ddb27e2b85adafdbd08a7d09e72e5d5b175369e Mon Sep 17 00:00:00 2001 From: aligator Date: Fri, 27 May 2022 11:45:18 +0200 Subject: [PATCH] Cleanup code, pass err to scanFinish (#283) --- cursor.go | 1 - repository.go | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cursor.go b/cursor.go index d7442c9a..7c074e0c 100644 --- a/cursor.go +++ b/cursor.go @@ -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") } diff --git a/repository.go b/repository.go index 1eff48c9..29fabae8 100644 --- a/repository.go +++ b/repository.go @@ -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. @@ -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 }