Added statement.RawCols()

This commit is contained in:
evalphobia 2016-02-01 20:25:42 +09:00
parent 24c1f3c15a
commit e5a5441067
3 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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