From 2afb265ea41470b4315bc9157f1b006b3f1949b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 13 Jan 2024 14:19:19 +0100 Subject: [PATCH] v0.0.371 --- goextVersion.go | 4 ++-- sq/database.go | 4 ++-- sq/transaction.go | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/goextVersion.go b/goextVersion.go index d6eefbe..9180327 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.370" +const GoextVersion = "0.0.371" -const GoextVersionTimestamp = "2024-01-13T14:10:25+0100" +const GoextVersionTimestamp = "2024-01-13T14:19:19+0100" diff --git a/sq/database.go b/sq/database.go index 8477e93..e562dc8 100644 --- a/sq/database.go +++ b/sq/database.go @@ -46,7 +46,7 @@ func (db *database) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Resul for _, v := range db.lstr { err := v.PreExec(ctx, nil, &sqlstr, &prep) if err != nil { - return nil, err + return nil, exerr.Wrap(err, "failed to call SQL pre-exec listener").Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build() } } @@ -67,7 +67,7 @@ func (db *database) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx.Ro for _, v := range db.lstr { err := v.PreQuery(ctx, nil, &sqlstr, &prep) if err != nil { - return nil, err + return nil, exerr.Wrap(err, "failed to call SQL pre-query listener").Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build() } } diff --git a/sq/transaction.go b/sq/transaction.go index a6306cc..5608dd6 100644 --- a/sq/transaction.go +++ b/sq/transaction.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "github.com/jmoiron/sqlx" + "gogs.mikescher.com/BlackForestBytes/goext/exerr" "gogs.mikescher.com/BlackForestBytes/goext/langext" ) @@ -48,7 +49,7 @@ func (tx *transaction) Rollback() error { for _, v := range tx.db.lstr { err := v.PreTxRollback(tx.id) if err != nil { - return err + return exerr.Wrap(err, "failed to call SQL pre-rollback listener").Int("tx.id", int(tx.id)).Build() } } @@ -69,7 +70,7 @@ func (tx *transaction) Commit() error { for _, v := range tx.db.lstr { err := v.PreTxCommit(tx.id) if err != nil { - return err + return exerr.Wrap(err, "failed to call SQL pre-commit listener").Int("tx.id", int(tx.id)).Build() } } @@ -91,7 +92,7 @@ func (tx *transaction) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Re for _, v := range tx.db.lstr { err := v.PreExec(ctx, langext.Ptr(tx.id), &sqlstr, &prep) if err != nil { - return nil, err + return nil, exerr.Wrap(err, "failed to call SQL pre-exec listener").Int("tx.id", int(tx.id)).Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build() } } @@ -106,7 +107,7 @@ func (tx *transaction) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Re } if err != nil { - return nil, err + return nil, exerr.Wrap(err, "Failed to [exec] sql statement").Int("tx.id", int(tx.id)).Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build() } return res, nil } @@ -116,7 +117,7 @@ func (tx *transaction) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx for _, v := range tx.db.lstr { err := v.PreQuery(ctx, langext.Ptr(tx.id), &sqlstr, &prep) if err != nil { - return nil, err + return nil, exerr.Wrap(err, "failed to call SQL pre-query listener").Int("tx.id", int(tx.id)).Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build() } } @@ -131,7 +132,7 @@ func (tx *transaction) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx } if err != nil { - return nil, err + return nil, exerr.Wrap(err, "Failed to [query] sql statement").Int("tx.id", int(tx.id)).Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build() } return rows, nil }