This commit is contained in:
Mike Schwörer 2022-12-21 14:39:59 +01:00
parent 5e99e07f40
commit fff609db4a
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ func (db *database) SetListener(listener Listener) {
func (db *database) Exec(ctx context.Context, sql string, prep PP) (sql.Result, error) { func (db *database) Exec(ctx context.Context, sql string, prep PP) (sql.Result, error) {
if db.lstr != nil { if db.lstr != nil {
db.lstr.OnExec(nil, sql, &prep) db.lstr.OnExec(nil, &sql, &prep)
} }
res, err := db.db.NamedExecContext(ctx, sql, prep) res, err := db.db.NamedExecContext(ctx, sql, prep)
@ -48,7 +48,7 @@ func (db *database) Exec(ctx context.Context, sql string, prep PP) (sql.Result,
func (db *database) Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error) { func (db *database) Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error) {
if db.lstr != nil { if db.lstr != nil {
db.lstr.OnQuery(nil, sql, &prep) db.lstr.OnQuery(nil, &sql, &prep)
} }
rows, err := db.db.NamedQueryContext(ctx, sql, prep) rows, err := db.db.NamedQueryContext(ctx, sql, prep)

View File

@ -1,8 +1,8 @@
package sq package sq
type Listener interface { type Listener interface {
OnQuery(txID *uint16, sql string, params *PP) OnQuery(txID *uint16, sql *string, params *PP)
OnExec(txID *uint16, sql string, params *PP) OnExec(txID *uint16, sql *string, params *PP)
OnPing() OnPing()
OnTxBegin(txid uint16) OnTxBegin(txid uint16)
OnTxCommit(txid uint16) OnTxCommit(txid uint16)

View File

@ -46,7 +46,7 @@ func (tx *transaction) Commit() error {
func (tx *transaction) Exec(ctx context.Context, sql string, prep PP) (sql.Result, error) { func (tx *transaction) Exec(ctx context.Context, sql string, prep PP) (sql.Result, error) {
if tx.lstr != nil { if tx.lstr != nil {
tx.lstr.OnExec(langext.Ptr(tx.id), sql, &prep) tx.lstr.OnExec(langext.Ptr(tx.id), &sql, &prep)
} }
res, err := tx.tx.NamedExecContext(ctx, sql, prep) res, err := tx.tx.NamedExecContext(ctx, sql, prep)
@ -58,7 +58,7 @@ func (tx *transaction) Exec(ctx context.Context, sql string, prep PP) (sql.Resul
func (tx *transaction) Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error) { func (tx *transaction) Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error) {
if tx.lstr != nil { if tx.lstr != nil {
tx.lstr.OnQuery(langext.Ptr(tx.id), sql, &prep) tx.lstr.OnQuery(langext.Ptr(tx.id), &sql, &prep)
} }
rows, err := sqlx.NamedQueryContext(ctx, tx.tx, sql, prep) rows, err := sqlx.NamedQueryContext(ctx, tx.tx, sql, prep)