From 0e25da906f257405c3ae0008e05a11610ba56870 Mon Sep 17 00:00:00 2001 From: piyongcai Date: Sat, 22 Jan 2022 21:57:15 +0800 Subject: [PATCH] finisher_app.go Add ExecRaw Method. it use Do no processing and execute the original sql --- finisher_api.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/finisher_api.go b/finisher_api.go index 355d89bd..bbb1ba4d 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -662,3 +662,16 @@ func (db *DB) Exec(sql string, values ...interface{}) (tx *DB) { return tx.callbacks.Raw().Execute(tx) } + +// ExecRaw Do no processing and execute the original sql +func (db *DB) ExecRaw(sql string, values ...interface{}) (tx *DB) { + tx = db.getInstance() + + builder := strings.Builder{} + builder.WriteString(sql) + + tx.Statement.SQL = builder + tx.Statement.Vars = values + + return tx.callbacks.Raw().Execute(tx) +}