Pārlūkot izejas kodu

add BeforeExecProcessor

paddy 4 gadi atpakaļ
vecāks
revīzija
618e5bcea0
1 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 5 0
      session_raw.go

+ 5 - 0
session_raw.go

@@ -263,6 +263,8 @@ func (session *Session) queryResult(sqlStr string, args ...interface{}) (Result,
 	return rows2Result(rows)
 }
 
+var BeforeExecProcessor func(sqlStr string, args []interface{})
+
 func (session *Session) exec(sqlStr string, args ...interface{}) (sql.Result, error) {
 	defer session.resetStatement()
 
@@ -287,6 +289,9 @@ func (session *Session) exec(sqlStr string, args ...interface{}) (sql.Result, er
 			}
 		}
 	}
+	if BeforeExecProcessor != nil {
+		BeforeExecProcessor(sqlStr, args)
+	}
 
 	if !session.isAutoCommit {
 		return session.tx.ExecContext(session.ctx, sqlStr, args...)