hack for ql support
This commit is contained in:
parent
6cc6e18143
commit
29fd03b318
13
session.go
13
session.go
|
@ -614,11 +614,15 @@ func (session *Session) DropTable(beanOrTableName interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (statement *Statement) JoinColumns(cols []*core.Column) string {
|
||||
func (statement *Statement) JoinColumns(cols []*core.Column, includeTableName bool) string {
|
||||
var colnames = make([]string, len(cols))
|
||||
for i, col := range cols {
|
||||
if includeTableName {
|
||||
colnames[i] = statement.Engine.Quote(statement.TableName()) +
|
||||
"." + statement.Engine.Quote(col.Name)
|
||||
} else {
|
||||
colnames[i] = statement.Engine.Quote(col.Name)
|
||||
}
|
||||
}
|
||||
return strings.Join(colnames, ", ")
|
||||
}
|
||||
|
@ -630,11 +634,14 @@ func (statement *Statement) convertIdSql(sqlStr string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
colstrs := statement.JoinColumns(cols)
|
||||
colstrs := statement.JoinColumns(cols, false)
|
||||
sqls := splitNNoCase(sqlStr, " from ", 2)
|
||||
if len(sqls) != 2 {
|
||||
return ""
|
||||
}
|
||||
if statement.Engine.dialect.DBType() == "ql" {
|
||||
return fmt.Sprintf("SELECT id() FROM %v", sqls[1])
|
||||
}
|
||||
return fmt.Sprintf("SELECT %s FROM %v", colstrs, sqls[1])
|
||||
}
|
||||
return ""
|
||||
|
@ -3280,7 +3287,7 @@ func (statement *Statement) convertUpdateSql(sqlStr string) (string, string) {
|
|||
return "", ""
|
||||
}
|
||||
|
||||
colstrs := statement.JoinColumns(statement.RefTable.PKColumns())
|
||||
colstrs := statement.JoinColumns(statement.RefTable.PKColumns(), true)
|
||||
sqls := splitNNoCase(sqlStr, "where", 2)
|
||||
if len(sqls) != 2 {
|
||||
if len(sqls) == 1 {
|
||||
|
|
Loading…
Reference in New Issue