diff --git a/driver/gorm/map.go b/driver/gorm/map.go index ce3af98..0b0dbac 100644 --- a/driver/gorm/map.go +++ b/driver/gorm/map.go @@ -10,6 +10,7 @@ func TakeMap(tx *gorm.DB) (map[string]interface{}, error) { if err != nil { return nil, err } + defer rows.Close() if !rows.Next() { return nil, nil @@ -28,6 +29,7 @@ func FindMap(tx *gorm.DB) ([]map[string]interface{}, error) { if err != nil { return nil, err } + defer rows.Close() return rowsMap(rows) } diff --git a/driver/gorm/paginator_test.go b/driver/gorm/paginator_test.go index 5c981ef..e10778a 100644 --- a/driver/gorm/paginator_test.go +++ b/driver/gorm/paginator_test.go @@ -27,6 +27,12 @@ func SetupDb(models ...interface{}) (*gormdb.DB, context.CancelFunc) { panic(fmt.Sprintf("Failed to connect to db: %v", err)) } + sqlDB, err := db.DB() + if err != nil { + panic(fmt.Sprintf("Failed to get db: %v", err)) + } + sqlDB.SetMaxOpenConns(1) + db.AutoMigrate(models...) ctx, cancel := context.WithCancel(context.Background())