From 793ba92c9f743d1755913bcb836b07973d4ca4bc Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 17 Apr 2026 15:29:47 +0200 Subject: basic test coverage for Insert, Update, Delete --- query.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'query.go') diff --git a/query.go b/query.go index 1b9ae46..7810bac 100644 --- a/query.go +++ b/query.go @@ -63,7 +63,7 @@ func (s Store[R]) Insert(db Handle, records ...R) (returnedRecords []R, returned for idx := range records { v := reflect.ValueOf(&records[idx]).Elem() for idx, index := range argumentIndexes { - argumentSlots[idx] = v.FieldByIndex(index).Addr().Interface() + argumentSlots[idx] = v.FieldByIndex(index).Interface() } if s.dialect.UsesLastInsertID() { @@ -95,7 +95,12 @@ func (s Store[R]) Insert(db Handle, records ...R) (returnedRecords []R, returned for idx, index := range scanIndexes { scanSlots[idx] = v.FieldByIndex(index).Addr().Interface() } - err := stmt.QueryRow(argumentSlots...).Scan(scanSlots...) + var err error + if stmt == nil { + err = db.QueryRow(s.plan.Insert.Query, argumentSlots...).Scan(scanSlots...) + } else { + err = stmt.QueryRow(argumentSlots...).Scan(scanSlots...) + } if err != nil { return nil, fmt.Errorf("during QueryRow() for record with idx = %d: %w", idx, err) } -- cgit v1.2.3