Skip to content

Commit

Permalink
fix: Add Go controller comment
Browse files Browse the repository at this point in the history
  • Loading branch information
duffn committed Jul 20, 2024
1 parent c447d21 commit 11051be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions go/database/sql/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func (conn *sqlCommenterConn) withComment(ctx context.Context, query string) str
commentsMap[core.Action] = ctx.Value(core.Action).(string)
}

if config.EnableController && (ctx.Value(core.Controller) != nil) {
commentsMap[core.Controller] = ctx.Value(core.Controller).(string)
}

// `driver` information should not be coming from framework.
// So, explicitly adding that here.
if config.EnableDBDriver {
Expand Down
2 changes: 1 addition & 1 deletion go/database/sql/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestWithComment_WithContext(t *testing.T) {
},
),
query: "SELECT 1;",
wantQuery: "SELECT 1/*action='any+action',application='app-1',db_driver='database%2Fsql%3Apostgres',framework='custom-golang',route='listData'*/;",
wantQuery: "SELECT 1/*action='any+action',application='app-1',controller='custom-controller',db_driver='database%2Fsql%3Apostgres',framework='custom-golang',route='listData'*/;",
},
}
for _, tc := range testCases {
Expand Down

0 comments on commit 11051be

Please sign in to comment.