mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-57517] Add exact user ID lookup to the search query for Users (#26661)
* [MM-57517] Add exact user ID lookup to the search query for Users * Fix lint * Add test for ID search
This commit is contained in:
parent
0ffbc75cfd
commit
39bb8a1121
@ -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...)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user