Remove use of dialect.LikeStr (#104460)
* Fix TestIntegrationUpdatingProvisionionedDashboards* tests when running on Spanner by fixing case-insensitive search for dashboard title. * Fix use of case-insensitive LIKE when running on Spanner. * Fix use of LikeStr in anonstore. * Fix use of LikeStr in ngalert/store and org/orgimpl. * Fix use of LikeStr in queryhistory search. * Fix use of LikeStr in serviceaccounts. * Fix use of LikeStr in serviceaccounts. * Fix use of LikeStr in services/team. * Remove LikeStr method.
This commit is contained in:
@@ -585,9 +585,11 @@ func (ss *sqlStore) SearchOrgUsers(ctx context.Context, query *org.SearchOrgUser
|
||||
}
|
||||
|
||||
if query.Query != "" {
|
||||
queryWithWildcards := "%" + query.Query + "%"
|
||||
whereConditions = append(whereConditions, "(email "+ss.dialect.LikeStr()+" ? OR name "+ss.dialect.LikeStr()+" ? OR login "+ss.dialect.LikeStr()+" ?)")
|
||||
whereParams = append(whereParams, queryWithWildcards, queryWithWildcards, queryWithWildcards)
|
||||
sql1, param1 := ss.dialect.LikeOperator("email", true, query.Query, true)
|
||||
sql2, param2 := ss.dialect.LikeOperator("name", true, query.Query, true)
|
||||
sql3, param3 := ss.dialect.LikeOperator("login", true, query.Query, true)
|
||||
whereConditions = append(whereConditions, fmt.Sprintf("(%s OR %s OR %s)", sql1, sql2, sql3))
|
||||
whereParams = append(whereParams, param1, param2, param3)
|
||||
}
|
||||
|
||||
if len(whereConditions) > 0 {
|
||||
|
||||
@@ -405,7 +405,7 @@ func TestIntegrationOrgUserDataAccess(t *testing.T) {
|
||||
t.Run("Can get organization users with query", func(t *testing.T) {
|
||||
query := org.SearchOrgUsersQuery{
|
||||
OrgID: ac1.OrgID,
|
||||
Query: "ac1",
|
||||
Query: "AC1", // Use different-case to test case-insensitive search
|
||||
User: &user.SignedInUser{
|
||||
OrgID: ac1.OrgID,
|
||||
Permissions: map[int64]map[string][]string{ac1.OrgID: {accesscontrol.ActionOrgUsersRead: {accesscontrol.ScopeUsersAll}}},
|
||||
@@ -420,7 +420,7 @@ func TestIntegrationOrgUserDataAccess(t *testing.T) {
|
||||
t.Run("Can get organization users with query and limit", func(t *testing.T) {
|
||||
query := org.SearchOrgUsersQuery{
|
||||
OrgID: ac1.OrgID,
|
||||
Query: "ac",
|
||||
Query: "aC", // Use mixed-case to test case-insensitive search
|
||||
Limit: 1,
|
||||
User: &user.SignedInUser{
|
||||
OrgID: ac1.OrgID,
|
||||
|
||||
Reference in New Issue
Block a user