paddy пре 4 година
родитељ
комит
618e5bcea0
1 измењених фајлова са 5 додато и 0 уклоњено
  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...)