improve function

This commit is contained in:
Lunny Xiao 2023-07-12 13:43:29 +08:00
parent 0fdecc7777
commit e388ef801d
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 14 additions and 16 deletions

View File

@ -478,28 +478,26 @@ func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interfac
}
func (statement *Statement) genSelectColumnStr() string {
// manually select columns
if len(statement.SelectStr) > 0 {
return statement.SelectStr
}
columnStr := statement.ColumnStr()
if len(statement.joins) == 0 {
if columnStr == "" {
if statement.GroupByStr != "" {
columnStr = statement.quoteColumnStr(statement.GroupByStr)
} else {
columnStr = statement.genColumnStr()
}
}
} else {
if columnStr == "" {
if statement.GroupByStr != "" {
columnStr = statement.quoteColumnStr(statement.GroupByStr)
} else {
columnStr = "*"
}
}
if columnStr != "" {
return columnStr
}
// autodetect columns
if statement.GroupByStr != "" {
return statement.quoteColumnStr(statement.GroupByStr)
}
if len(statement.joins) != 0 {
return "*"
}
columnStr = statement.genColumnStr()
if columnStr == "" {
columnStr = "*"
}