diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-04-17 15:29:47 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-04-17 15:29:47 +0200 |
| commit | 793ba92c9f743d1755913bcb836b07973d4ca4bc (patch) | |
| tree | cdfcad6e89da933302f3d0505400855fc2ca4fd6 /query.go | |
| parent | 52f44287216b47149da9eb3f038408447f0e5981 (diff) | |
| download | go-oblast-793ba92c9f743d1755913bcb836b07973d4ca4bc.tar.gz | |
basic test coverage for Insert, Update, Delete
Diffstat (limited to 'query.go')
| -rw-r--r-- | query.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) } |
