Cols("*") error

when my code Cols("*")   it will Gen. Sql like
SELECT "*" FROM.   it is no work in postgresql.
This commit is contained in:
hzmnet 2015-06-29 00:20:31 +08:00
parent f2ff39264f
commit 4cc9187876
1 changed files with 12 additions and 4 deletions

View File

@ -782,7 +782,15 @@ func (statement *Statement) Cols(columns ...string) *Statement {
for _, nc := range newColumns {
statement.columnMap[strings.ToLower(nc)] = true
}
// by hzm
if len(newColumns) == 1 {
statement.ColumnStr = newColumns
} else {
statement.ColumnStr = statement.Engine.Quote(strings.Join(newColumns, statement.Engine.Quote(", ")))
}
if strings.Contains(statement.ColumnStr, ".") {
statement.ColumnStr = strings.Replace(statement.ColumnStr, ".", statement.Engine.Quote("."), -1)
}