|
|
@@ -6,7 +6,6 @@ package xorm
|
|
|
|
|
|
import (
|
|
|
"database/sql/driver"
|
|
|
- "errors"
|
|
|
"fmt"
|
|
|
"reflect"
|
|
|
"strings"
|
|
|
@@ -426,7 +425,7 @@ func (statement *Statement) buildUpdates(bean interface{},
|
|
|
continue
|
|
|
}
|
|
|
} else {
|
|
|
- //TODO: how to handler?
|
|
|
+ // TODO: how to handler?
|
|
|
panic("not supported")
|
|
|
}
|
|
|
} else {
|
|
|
@@ -607,21 +606,9 @@ func (statement *Statement) getExpr() map[string]exprParam {
|
|
|
|
|
|
func (statement *Statement) col2NewColsWithQuote(columns ...string) []string {
|
|
|
newColumns := make([]string, 0)
|
|
|
+ quotes := append(strings.Split(statement.Engine.Quote(""), ""), "`")
|
|
|
for _, col := range columns {
|
|
|
- col = strings.Replace(col, "`", "", -1)
|
|
|
- col = strings.Replace(col, statement.Engine.QuoteStr(), "", -1)
|
|
|
- ccols := strings.Split(col, ",")
|
|
|
- for _, c := range ccols {
|
|
|
- fields := strings.Split(strings.TrimSpace(c), ".")
|
|
|
- if len(fields) == 1 {
|
|
|
- newColumns = append(newColumns, statement.Engine.quote(fields[0]))
|
|
|
- } else if len(fields) == 2 {
|
|
|
- newColumns = append(newColumns, statement.Engine.quote(fields[0])+"."+
|
|
|
- statement.Engine.quote(fields[1]))
|
|
|
- } else {
|
|
|
- panic(errors.New("unwanted colnames"))
|
|
|
- }
|
|
|
- }
|
|
|
+ newColumns = append(newColumns, statement.Engine.Quote(eraseAny(col, quotes...)))
|
|
|
}
|
|
|
return newColumns
|
|
|
}
|
|
|
@@ -792,7 +779,9 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
|
|
|
return statement
|
|
|
}
|
|
|
tbs := strings.Split(tp.TableName(), ".")
|
|
|
- var aliasName = strings.Trim(tbs[len(tbs)-1], statement.Engine.QuoteStr())
|
|
|
+ quotes := append(strings.Split(statement.Engine.Quote(""), ""), "`")
|
|
|
+
|
|
|
+ var aliasName = strings.Trim(tbs[len(tbs)-1], strings.Join(quotes, ""))
|
|
|
fmt.Fprintf(&buf, "(%s) %s ON %v", subSQL, aliasName, condition)
|
|
|
statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
|
|
|
case *builder.Builder:
|
|
|
@@ -802,7 +791,9 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
|
|
|
return statement
|
|
|
}
|
|
|
tbs := strings.Split(tp.TableName(), ".")
|
|
|
- var aliasName = strings.Trim(tbs[len(tbs)-1], statement.Engine.QuoteStr())
|
|
|
+ quotes := append(strings.Split(statement.Engine.Quote(""), ""), "`")
|
|
|
+
|
|
|
+ var aliasName = strings.Trim(tbs[len(tbs)-1], strings.Join(quotes, ""))
|
|
|
fmt.Fprintf(&buf, "(%s) %s ON %v", subSQL, aliasName, condition)
|
|
|
statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
|
|
|
default:
|
|
|
@@ -1272,7 +1263,7 @@ func (statement *Statement) convertUpdateSQL(sqlStr string) (string, string) {
|
|
|
|
|
|
var whereStr = sqls[1]
|
|
|
|
|
|
- //TODO: for postgres only, if any other database?
|
|
|
+ // TODO: for postgres only, if any other database?
|
|
|
var paraStr string
|
|
|
if statement.Engine.dialect.DBType() == core.POSTGRES {
|
|
|
paraStr = "$"
|