persisting primary keys through rows

This commit is contained in:
2025-09-26 16:29:36 -04:00
parent 75f6ef8b5b
commit 92b673cb46

View File

@@ -17,13 +17,18 @@ type MockResults struct {
Rows [][]driver.Value 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 { if exampleObj == nil {
return nil, errors.New("exampleObj cannot be nil") return nil, errors.New("exampleObj cannot be nil")
} }
if rowCount == 0 { if rowCount == 0 {
rowCount = 1 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) retType := reflect.TypeOf(exampleObj)
maxFieldCount := retType.NumField() maxFieldCount := retType.NumField()