From 92b673cb46871137956cc1c3c75c713749abf345 Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 26 Sep 2025 16:29:36 -0400 Subject: [PATCH] persisting primary keys through rows --- lazy.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lazy.go b/lazy.go index f70676c..79cb897 100644 --- a/lazy.go +++ b/lazy.go @@ -17,13 +17,18 @@ type MockResults struct { Rows [][]driver.Value } -func GenerateRandomResults(query string, exampleObj any, keyVal any, rowCount int) (*MockResults, error) { +func GenerateRandomResults(query string, exampleObj any, keyVal []any, rowCount int) (*MockResults, error) { if exampleObj == nil { return nil, errors.New("exampleObj cannot be nil") } if rowCount == 0 { rowCount = 1 } + if len(keyVal) != 0 { + if len(keyVal) != rowCount { + return nil, errors.New("you must provide a key for each row") + } + } retType := reflect.TypeOf(exampleObj) maxFieldCount := retType.NumField()