This commit is contained in:
Lunny Xiao 2015-03-12 22:26:45 +08:00
parent a068aadd27
commit ba131dd9a0
2 changed files with 25 additions and 9 deletions

View File

@ -1173,13 +1173,21 @@ func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{})
var columnStr string = session.Statement.ColumnStr
if session.Statement.JoinStr == "" {
if columnStr == "" {
if session.Statement.GroupByStr != "" {
columnStr = session.Statement.Engine.Quote(strings.Replace(session.Statement.GroupByStr, ",", session.Engine.Quote(","), -1))
} else {
columnStr = session.Statement.genColumnStr()
}
}
} else {
if columnStr == "" {
if session.Statement.GroupByStr != "" {
columnStr = session.Statement.Engine.Quote(strings.Replace(session.Statement.GroupByStr, ",", session.Engine.Quote(","), -1))
} else {
columnStr = "*"
}
}
}
session.Statement.attachInSql()

View File

@ -1142,15 +1142,23 @@ func (statement *Statement) genGetSql(bean interface{}) (string, []interface{})
statement.BeanArgs = args
var columnStr string = statement.ColumnStr
if statement.JoinStr == "" {
if columnStr == "" {
if len(statement.JoinStr) == 0 {
if len(columnStr) == 0 {
if statement.GroupByStr != "" {
columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1))
} else {
columnStr = statement.genColumnStr()
}
}
} else {
if len(columnStr) == 0 {
if statement.GroupByStr != "" {
columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1))
} else {
if columnStr == "" {
columnStr = "*"
}
}
}
statement.attachInSql() // !admpub! fix bug:Iterate func missing "... IN (...)"
return statement.genSelectSql(columnStr), append(statement.Params, statement.BeanArgs...)
@ -1198,12 +1206,12 @@ func (statement *Statement) genCountSql(bean interface{}) (string, []interface{}
}
func (statement *Statement) genSelectSql(columnStr string) (a string) {
if statement.GroupByStr != "" {
/*if statement.GroupByStr != "" {
if columnStr == "" {
columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1))
}
//statement.GroupByStr = columnStr
}
}*/
var distinct string
if statement.IsDistinct {
distinct = "DISTINCT "