diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go
index 0e606c065..f2241d756 100644
--- a/database/gdb/gdb.go
+++ b/database/gdb/gdb.go
@@ -103,11 +103,11 @@ type DB interface {
Tables(schema ...string) (tables []string, err error)
TableFields(table string, schema ...string) (map[string]*TableField, error)
- // HandleSqlBeforeExec is a hook function, which deals with the sql string before
+ // HandleSqlBeforeCommit is a hook function, which deals with the sql string before
// it's committed to underlying driver. The parameter specifies the current
// database connection operation object. You can modify the sql string and its
// arguments as you wish before they're committed to driver.
- HandleSqlBeforeExec(link Link, query string, args []interface{}) (string, []interface{})
+ HandleSqlBeforeCommit(link Link, query string, args []interface{}) (string, []interface{})
// Internal methods.
filterFields(schema, table string, data map[string]interface{}) map[string]interface{}
diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go
index 2cc92ec12..077684a54 100644
--- a/database/gdb/gdb_core.go
+++ b/database/gdb/gdb_core.go
@@ -57,7 +57,7 @@ func (c *Core) Query(query string, args ...interface{}) (rows *sql.Rows, err err
// through given link object and returns the execution result.
func (c *Core) DoQuery(link Link, query string, args ...interface{}) (rows *sql.Rows, err error) {
query, args = formatQuery(query, args)
- query, args = c.DB.HandleSqlBeforeExec(link, query, args)
+ query, args = c.DB.HandleSqlBeforeCommit(link, query, args)
if c.DB.GetDebug() {
mTime1 := gtime.TimestampMilli()
rows, err = link.Query(query, args...)
@@ -96,7 +96,7 @@ func (c *Core) Exec(query string, args ...interface{}) (result sql.Result, err e
// through given link object and returns the execution result.
func (c *Core) DoExec(link Link, query string, args ...interface{}) (result sql.Result, err error) {
query, args = formatQuery(query, args)
- query, args = c.DB.HandleSqlBeforeExec(link, query, args)
+ query, args = c.DB.HandleSqlBeforeCommit(link, query, args)
if c.DB.GetDebug() {
mTime1 := gtime.TimestampMilli()
result, err = link.Exec(query, args...)
diff --git a/database/gdb/gdb_core_utility.go b/database/gdb/gdb_core_utility.go
index d127de77e..5c7e13005 100644
--- a/database/gdb/gdb_core_utility.go
+++ b/database/gdb/gdb_core_utility.go
@@ -59,9 +59,9 @@ func (c *Core) GetChars() (charLeft string, charRight string) {
return "", ""
}
-// HandleSqlBeforeExec handles the sql before posts it to database.
+// HandleSqlBeforeCommit handles the sql before posts it to database.
// It does nothing in default.
-func (c *Core) HandleSqlBeforeExec(sql string) string {
+func (c *Core) HandleSqlBeforeCommit(sql string) string {
return sql
}
diff --git a/database/gdb/gdb_driver_mssql.go b/database/gdb/gdb_driver_mssql.go
index 4e64b9689..a6253caf3 100644
--- a/database/gdb/gdb_driver_mssql.go
+++ b/database/gdb/gdb_driver_mssql.go
@@ -59,8 +59,8 @@ func (d *DriverMssql) GetChars() (charLeft string, charRight string) {
return "\"", "\""
}
-// HandleSqlBeforeExec deals with the sql string before commits it to underlying sql driver.
-func (d *DriverMssql) HandleSqlBeforeExec(link Link, query string, args []interface{}) (string, []interface{}) {
+// HandleSqlBeforeCommit deals with the sql string before commits it to underlying sql driver.
+func (d *DriverMssql) HandleSqlBeforeCommit(link Link, query string, args []interface{}) (string, []interface{}) {
var index int
// Convert place holder char '?' to string "@px".
str, _ := gregex.ReplaceStringFunc("\\?", query, func(s string) string {
diff --git a/database/gdb/gdb_driver_mysql.go b/database/gdb/gdb_driver_mysql.go
index fca304d56..2e781fd86 100644
--- a/database/gdb/gdb_driver_mysql.go
+++ b/database/gdb/gdb_driver_mysql.go
@@ -52,8 +52,8 @@ func (d *DriverMysql) GetChars() (charLeft string, charRight string) {
return "`", "`"
}
-// HandleSqlBeforeExec handles the sql before posts it to database.
-func (d *DriverMysql) HandleSqlBeforeExec(link Link, sql string, args []interface{}) (string, []interface{}) {
+// HandleSqlBeforeCommit handles the sql before posts it to database.
+func (d *DriverMysql) HandleSqlBeforeCommit(link Link, sql string, args []interface{}) (string, []interface{}) {
return sql, args
}
diff --git a/database/gdb/gdb_driver_oracle.go b/database/gdb/gdb_driver_oracle.go
index cb7e394ce..fbd48c339 100644
--- a/database/gdb/gdb_driver_oracle.go
+++ b/database/gdb/gdb_driver_oracle.go
@@ -63,8 +63,8 @@ func (d *DriverOracle) GetChars() (charLeft string, charRight string) {
return "\"", "\""
}
-// HandleSqlBeforeExec deals with the sql string before commits it to underlying sql driver.
-func (d *DriverOracle) HandleSqlBeforeExec(link Link, query string, args []interface{}) (string, []interface{}) {
+// HandleSqlBeforeCommit deals with the sql string before commits it to underlying sql driver.
+func (d *DriverOracle) HandleSqlBeforeCommit(link Link, query string, args []interface{}) (string, []interface{}) {
var index int
// Convert place holder char '?' to string ":x".
str, _ := gregex.ReplaceStringFunc("\\?", query, func(s string) string {
diff --git a/database/gdb/gdb_driver_pgsql.go b/database/gdb/gdb_driver_pgsql.go
index 5f08c1996..76db87476 100644
--- a/database/gdb/gdb_driver_pgsql.go
+++ b/database/gdb/gdb_driver_pgsql.go
@@ -58,8 +58,8 @@ func (d *DriverPgsql) GetChars() (charLeft string, charRight string) {
return "\"", "\""
}
-// HandleSqlBeforeExec deals with the sql string before commits it to underlying sql driver.
-func (d *DriverPgsql) HandleSqlBeforeExec(link Link, sql string, args []interface{}) (string, []interface{}) {
+// HandleSqlBeforeCommit deals with the sql string before commits it to underlying sql driver.
+func (d *DriverPgsql) HandleSqlBeforeCommit(link Link, sql string, args []interface{}) (string, []interface{}) {
var index int
// Convert place holder char '?' to string "$x".
sql, _ = gregex.ReplaceStringFunc("\\?", sql, func(s string) string {
diff --git a/database/gdb/gdb_driver_sqlite.go b/database/gdb/gdb_driver_sqlite.go
index 7703e4509..e23442316 100644
--- a/database/gdb/gdb_driver_sqlite.go
+++ b/database/gdb/gdb_driver_sqlite.go
@@ -50,10 +50,10 @@ func (d *DriverSqlite) GetChars() (charLeft string, charRight string) {
return "`", "`"
}
-// HandleSqlBeforeExec deals with the sql string before commits it to underlying sql driver.
+// HandleSqlBeforeCommit deals with the sql string before commits it to underlying sql driver.
// @todo 需要增加对Save方法的支持,可使用正则来实现替换,
// @todo 将ON DUPLICATE KEY UPDATE触发器修改为两条SQL语句(INSERT OR IGNORE & UPDATE)
-func (d *DriverSqlite) HandleSqlBeforeExec(link Link, sql string, args []interface{}) (string, []interface{}) {
+func (d *DriverSqlite) HandleSqlBeforeCommit(link Link, sql string, args []interface{}) (string, []interface{}) {
return sql, args
}
diff --git a/database/gdb/gdb_unit_z_driver_test.go b/database/gdb/gdb_unit_z_driver_test.go
index 67be2da7a..f4c125a6e 100644
--- a/database/gdb/gdb_unit_z_driver_test.go
+++ b/database/gdb/gdb_unit_z_driver_test.go
@@ -16,9 +16,9 @@ import (
// MyDriver is a custom database driver, which is used for testing only.
// For simplifying the unit testing case purpose, MyDriver struct inherits the mysql driver
-// gdb.DriverMysql and overwrites its function HandleSqlBeforeExec.
-// So if there's any sql execution, it goes through MyDriver.HandleSqlBeforeExec firstly and
-// then gdb.DriverMysql.HandleSqlBeforeExec.
+// gdb.DriverMysql and overwrites its function HandleSqlBeforeCommit.
+// So if there's any sql execution, it goes through MyDriver.HandleSqlBeforeCommit firstly and
+// then gdb.DriverMysql.HandleSqlBeforeCommit.
// You can call it sql "HOOK" or "HiJack" as your will.
type MyDriver struct {
*gdb.DriverMysql
@@ -39,11 +39,11 @@ func (d *MyDriver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error) {
}, nil
}
-// HandleSqlBeforeExec handles the sql before posts it to database.
+// HandleSqlBeforeCommit handles the sql before posts it to database.
// It here overwrites the same method of gdb.DriverMysql and makes some custom changes.
-func (d *MyDriver) HandleSqlBeforeExec(link gdb.Link, sql string, args []interface{}) (string, []interface{}) {
+func (d *MyDriver) HandleSqlBeforeCommit(link gdb.Link, sql string, args []interface{}) (string, []interface{}) {
latestSqlString.Set(sql)
- return d.DriverMysql.HandleSqlBeforeExec(link, sql, args)
+ return d.DriverMysql.HandleSqlBeforeCommit(link, sql, args)
}
func init() {