diff --git a/server/channels/store/sqlstore/user_store.go b/server/channels/store/sqlstore/user_store.go index f08de13d4e..67d897c5f6 100644 --- a/server/channels/store/sqlstore/user_store.go +++ b/server/channels/store/sqlstore/user_store.go @@ -1613,6 +1613,8 @@ func generateSearchQuery(query sq.SelectBuilder, terms []string, fields []string } termArgs = append(termArgs, fmt.Sprintf("%%%s%%", strings.TrimLeft(term, "@"))) } + searchFields = append(searchFields, "Id = ?") + termArgs = append(termArgs, strings.TrimLeft(term, "@")) query = query.Where(fmt.Sprintf("(%s)", strings.Join(searchFields, " OR ")), termArgs...) } diff --git a/server/channels/store/storetest/user_store.go b/server/channels/store/storetest/user_store.go index 9d58cfbb8e..dba8680398 100644 --- a/server/channels/store/storetest/user_store.go +++ b/server/channels/store/storetest/user_store.go @@ -2862,6 +2862,30 @@ func testUserStoreSearch(t *testing.T, rctx request.CTX, ss store.Store) { }, []*model.User{u3}, }, + { + "search for Id of u1", + t1id, + u1.Id, + &model.UserSearchOptions{ + AllowFullNames: true, + Limit: model.UserSearchDefaultLimit, + Roles: []string{}, + TeamRoles: []string{}, + }, + []*model.User{u1}, + }, + { + "search for partial Id of u1", + t1id, + u1.Id[:len(u1.Id)-1], + &model.UserSearchOptions{ + AllowFullNames: true, + Limit: model.UserSearchDefaultLimit, + Roles: []string{}, + TeamRoles: []string{}, + }, + []*model.User{}, + }, } for _, testCase := range testCases {