diff --git a/session.go b/session.go index b33955fdc..91ec7ecc2 100644 --- a/session.go +++ b/session.go @@ -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) diff --git a/session_query.go b/session_query.go index 21c00b8d7..3652ddd5d 100644 --- a/session_query.go +++ b/session_query.go @@ -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 }