Skip to content

Commit 871c1c8

Browse files
authored
fix: Add Go controller comment (google#280)
1 parent c447d21 commit 871c1c8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

go/database/sql/connection.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (conn *sqlCommenterConn) withComment(ctx context.Context, query string) str
101101
commentsMap[core.Action] = ctx.Value(core.Action).(string)
102102
}
103103

104+
if config.EnableController && (ctx.Value(core.Controller) != nil) {
105+
commentsMap[core.Controller] = ctx.Value(core.Controller).(string)
106+
}
107+
104108
// `driver` information should not be coming from framework.
105109
// So, explicitly adding that here.
106110
if config.EnableDBDriver {

go/database/sql/connection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TestWithComment_WithContext(t *testing.T) {
147147
},
148148
),
149149
query: "SELECT 1;",
150-
wantQuery: "SELECT 1/*action='any+action',application='app-1',db_driver='database%2Fsql%3Apostgres',framework='custom-golang',route='listData'*/;",
150+
wantQuery: "SELECT 1/*action='any+action',application='app-1',controller='custom-controller',db_driver='database%2Fsql%3Apostgres',framework='custom-golang',route='listData'*/;",
151151
},
152152
}
153153
for _, tc := range testCases {

0 commit comments

Comments
 (0)