From a9b55f7fc8e522a74bfcdeedcee65ec25055c97a Mon Sep 17 00:00:00 2001 From: Fabian Kramm Date: Tue, 12 Nov 2024 09:02:33 +0100 Subject: [PATCH 1/2] fix: close mysql connection after create database Signed-off-by: Fabian Kramm --- pkg/drivers/mysql/mysql.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/drivers/mysql/mysql.go b/pkg/drivers/mysql/mysql.go index 2cf01b0d..bde3fae8 100644 --- a/pkg/drivers/mysql/mysql.go +++ b/pkg/drivers/mysql/mysql.go @@ -176,6 +176,7 @@ func createDBIfNotExist(dataSourceName string) error { if err != nil { return err } + defer db.Close() var exists bool err = db.QueryRow("SELECT 1 FROM information_schema.SCHEMATA WHERE schema_name = ?", dbName).Scan(&exists) @@ -195,6 +196,7 @@ func createDBIfNotExist(dataSourceName string) error { if err != nil { return err } + defer db.Close() if _, err = db.Exec(stmt); err != nil { return err } From 2d900551c3879dfbc6e0b2b7ca89ce2ae5988521 Mon Sep 17 00:00:00 2001 From: Fabian Kramm Date: Tue, 12 Nov 2024 10:59:14 +0100 Subject: [PATCH 2/2] chore: ignore redefines-builtin-id for insert Signed-off-by: Fabian Kramm --- pkg/drivers/generic/generic.go | 1 + pkg/server/types.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/drivers/generic/generic.go b/pkg/drivers/generic/generic.go index ef206f56..148895d9 100644 --- a/pkg/drivers/generic/generic.go +++ b/pkg/drivers/generic/generic.go @@ -406,6 +406,7 @@ func (d *Generic) IsFill(key string) bool { return strings.HasPrefix(key, "gap-") } +//nolint:revive func (d *Generic) Insert(ctx context.Context, key string, create, delete bool, createRevision, previousRevision int64, ttl int64, value, prevValue []byte) (id int64, err error) { if d.TranslateErr != nil { defer func() { diff --git a/pkg/server/types.go b/pkg/server/types.go index 83a87322..3e25cc6b 100644 --- a/pkg/server/types.go +++ b/pkg/server/types.go @@ -38,6 +38,7 @@ type Dialect interface { Count(ctx context.Context, prefix, startKey string, revision int64) (int64, int64, error) CurrentRevision(ctx context.Context) (int64, error) After(ctx context.Context, prefix string, rev, limit int64) (*sql.Rows, error) + //nolint:revive Insert(ctx context.Context, key string, create, delete bool, createRevision, previousRevision int64, ttl int64, value, prevValue []byte) (int64, error) GetRevision(ctx context.Context, revision int64) (*sql.Rows, error) DeleteRevision(ctx context.Context, revision int64) error