Describe the feature

Require a method to return raw sql for pipeline control, not just for logging.

Most case we use ....Scan(), ....First(), ...Find(), ...Delete(), ...Update, ... Updates ...Create to executed a sql.

However, in some case, we want to build a proxy db-api to do some pre-control for db operations.

It means we might transfer all orm executions to raw sql, and pass it to proxy db-api-srv.

Is there a way to get sql prepared befoe it 's executed.

It works like

// This will not execute insert into u values(...)
// Instead it just return string sql detail  " insert into u(...) values(...)", which is totally executable in database terminal.
sql :=db.PipeSQL().Model(u).Create(&u)
fmt.Println(sql)

sql := db.PipeSQL().Model(u).Update(...)
fmt.Println(sql)

// All cases below work like it:
// .PipeSQL()....Raw()...Scan()
// ..PipeSQL()......Delete()
// ..PipeSQL().....Exec()
// .PipeSQL()......Firrst
// ..PipeSQL().....Find
// 

Motivation

for pipeline control, need to prepare well-exeucable sql but do not execute it.

Related Issues

none

Comment From: li-jin-gou

可以看下这个 https://gorm.io/zh_CN/docs/sql_builder.html#ToSQL