Added GetSQLWhereClause
This commit is contained in:
parent
9cf19aaa35
commit
c4a4f834f7
@ -465,6 +465,31 @@ func (db *DB) GetSQL() string {
|
|||||||
return stmt
|
return stmt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *DB) GetSQL() string {
|
||||||
|
scope := db.NewScope(db.Value)
|
||||||
|
|
||||||
|
scope.prepareQuerySQL()
|
||||||
|
|
||||||
|
stmt := scope.SQL
|
||||||
|
for _, arg := range scope.SQLVars {
|
||||||
|
stmt = strings.Replace(stmt, "?", "'"+escape(fmt.Sprintf("%v", arg))+"'", 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return stmt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DB) GetSQLWhereClause() string {
|
||||||
|
scope := db.NewScope(db.Value)
|
||||||
|
|
||||||
|
stmt := scope.CombinedConditionSql()
|
||||||
|
|
||||||
|
for _, arg := range scope.SQLVars {
|
||||||
|
stmt = strings.Replace(stmt, "?", "'"+escape(fmt.Sprintf("%v", arg))+"'", 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return stmt
|
||||||
|
}
|
||||||
|
|
||||||
func escape(source string) string {
|
func escape(source string) string {
|
||||||
var j int = 0
|
var j int = 0
|
||||||
if len(source) == 0 {
|
if len(source) == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user