To support sql comment. #1344

Closed
in-han wants to merge 2 commits from in-han/master into master
2 changed files with 8 additions and 0 deletions

View File

@ -57,6 +57,7 @@ type Session struct {
//beforeSQLExec func(string, ...interface{})
lastSQL string
lastSQLArgs []interface{}
comment string
ctx context.Context
sessionType sessionType
@ -157,6 +158,12 @@ func (session *Session) Table(tableNameOrBean interface{}) *Session {
return session
}
// Set comment for select statement
func (session *Session) Comment(comment string) *Session {
session.comment = comment
return session
}
// Alias set the table alias
func (session *Session) Alias(alias string) *Session {
session.statement.Alias(alias)

View File

@ -20,6 +20,7 @@ func (session *Session) genQuerySQL(sqlOrArgs ...interface{}) (string, []interfa
return convertSQLOrArgs(sqlOrArgs...)
}
sqlStr = session.comment + sqlStr
if session.statement.RawSQL != "" {
return session.statement.RawSQL, session.statement.RawParams, nil
}