Browse Source

修复pgsql中关键字使用问题

master v1.1.1
lijianbin 14 hours ago
parent
commit
3b11f98fdc
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      common.go

+ 20
- 0
common.go View File

@ -0,0 +1,20 @@
package dbquery
import (
"git.tetele.net/tgo/helper"
"strings"
)
// 对执行前的sql语句进行处理--针对pgsql用
func SqlReplace(sql_s, sql_type string) string {
sql := strings.Replace(sql_s, "`", `"`, -1)
if sql_type == "add" {
sql = helper.StringJoin(sql, " RETURNING id")
}
sql = strings.Replace(sql, " user ", ` "user" `, -1)
sql = strings.Replace(sql, " user.", ` "user".`, -1)
return sql
}

Loading…
Cancel
Save