diff --git a/engine.go b/engine.go index a035a63d..9f9803d6 100644 --- a/engine.go +++ b/engine.go @@ -541,6 +541,12 @@ func (engine *Engine) Cols(columns ...string) *Session { return session.Cols(columns...) } +func (engine *Engine) RawCols(columns ...string) *Session { + session := engine.NewSession() + session.IsAutoClose = true + return session.RawCols(columns...) +} + func (engine *Engine) AllCols() *Session { session := engine.NewSession() session.IsAutoClose = true diff --git a/session.go b/session.go index eb0b7855..6de88c09 100644 --- a/session.go +++ b/session.go @@ -201,6 +201,12 @@ func (session *Session) Cols(columns ...string) *Session { return session } +// Method RawCols adds Cols without quotes +func (session *Session) RawCols(columns ...string) *Session { + session.Statement.RawCols(columns...) + return session +} + func (session *Session) AllCols() *Session { session.Statement.AllCols() return session diff --git a/statement.go b/statement.go index 444f4e93..2a16ab8d 100644 --- a/statement.go +++ b/statement.go @@ -864,6 +864,16 @@ func (statement *Statement) Cols(columns ...string) *Statement { return statement } +// Generate "col1, col2" statement without quotes +func (statement *Statement) RawCols(columns ...string) *Statement { + newColumns := col2NewCols(columns...) + for _, nc := range newColumns { + statement.columnMap[strings.ToLower(nc)] = true + } + statement.ColumnStr = strings.Join(newColumns, ", ") + return statement +} + // Update use only: update all columns func (statement *Statement) AllCols() *Statement { statement.useAllCols = true