Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

To support sql comment. #1344

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Session struct {
//beforeSQLExec func(string, ...interface{})
lastSQL string
lastSQLArgs []interface{}
comment string

ctx context.Context
sessionType sessionType
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions session_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down