This commit is contained in:
in-han 2019-10-08 13:15:37 +00:00 committed by GitHub
commit a4ab4ccdf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -57,6 +57,7 @@ type Session struct {
//beforeSQLExec func(string, ...interface{}) //beforeSQLExec func(string, ...interface{})
lastSQL string lastSQL string
lastSQLArgs []interface{} lastSQLArgs []interface{}
comment string
ctx context.Context ctx context.Context
sessionType sessionType sessionType sessionType
@ -157,6 +158,12 @@ func (session *Session) Table(tableNameOrBean interface{}) *Session {
return 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 // Alias set the table alias
func (session *Session) Alias(alias string) *Session { func (session *Session) Alias(alias string) *Session {
session.statement.Alias(alias) session.statement.Alias(alias)

View File

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