defer rows.Close()
This commit is contained in:
parent
8940fdf697
commit
3f533d568a
@ -42,6 +42,7 @@ func GetActionsForSource(db DB, source string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var names []string
|
||||
for rows.Next() {
|
||||
var name string
|
||||
@ -51,6 +52,9 @@ func GetActionsForSource(db DB, source string) ([]string, error) {
|
||||
}
|
||||
names = append(names, name)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return names, nil
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ func GetEnvs(db DB, source string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var envs []string
|
||||
for rows.Next() {
|
||||
var name string
|
||||
@ -23,6 +24,9 @@ func GetEnvs(db DB, source string) ([]string, error) {
|
||||
}
|
||||
envs = append(envs, fmt.Sprintf("%s=%s", name, value))
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return envs, nil
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,7 @@ func getItems(db DB, query string, args ...any) ([]Item, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Item
|
||||
for rows.Next() {
|
||||
var item Item
|
||||
@ -137,6 +138,9 @@ func getItems(db DB, query string, args ...any) ([]Item, error) {
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ func InitDatabase(db DB) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var exists bool
|
||||
for rows.Next() {
|
||||
@ -31,6 +32,9 @@ func InitDatabase(db DB) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if exists {
|
||||
return nil
|
||||
@ -56,6 +60,7 @@ func GetPendingMigrations(db DB) (map[string]bool, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var name string
|
||||
err = rows.Scan(&name)
|
||||
@ -64,6 +69,9 @@ func GetPendingMigrations(db DB) (map[string]bool, error) {
|
||||
}
|
||||
complete[name] = true
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return complete, nil
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ func GetSources(db DB) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var names []string
|
||||
for rows.Next() {
|
||||
var name string
|
||||
@ -33,6 +34,9 @@ func GetSources(db DB) ([]string, error) {
|
||||
}
|
||||
names = append(names, name)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return names, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user