Commit d9f01cb8 by Oleg Gaidarenko Committed by GitHub

SQLStore: use bool pointer instead of string (#18111)

parent c194ae1b
...@@ -147,9 +147,7 @@ type SearchUsersQuery struct { ...@@ -147,9 +147,7 @@ type SearchUsersQuery struct {
Limit int Limit int
AuthModule string AuthModule string
// We have to use string not bool, since there is cases when IsDisabled *bool
// we don't care if user is disabled or not
IsDisabled string
Result SearchUserQueryResult Result SearchUserQueryResult
} }
......
...@@ -456,14 +456,9 @@ func SearchUsers(query *models.SearchUsersQuery) error { ...@@ -456,14 +456,9 @@ func SearchUsers(query *models.SearchUsersQuery) error {
whereParams = append(whereParams, queryWithWildcards, queryWithWildcards, queryWithWildcards) whereParams = append(whereParams, queryWithWildcards, queryWithWildcards, queryWithWildcards)
} }
if query.IsDisabled != "" { if query.IsDisabled != nil {
param, err := strconv.ParseBool(query.IsDisabled)
if err != nil {
return err
}
whereConditions = append(whereConditions, "is_disabled = ?") whereConditions = append(whereConditions, "is_disabled = ?")
whereParams = append(whereParams, param) whereParams = append(whereParams, query.IsDisabled)
} }
if query.AuthModule != "" { if query.AuthModule != "" {
......
...@@ -194,7 +194,8 @@ func TestUserDataAccess(t *testing.T) { ...@@ -194,7 +194,8 @@ func TestUserDataAccess(t *testing.T) {
} }
}) })
query := models.SearchUsersQuery{IsDisabled: "false"} isDisabled := false
query := models.SearchUsersQuery{IsDisabled: &isDisabled}
err := SearchUsers(&query) err := SearchUsers(&query)
So(err, ShouldBeNil) So(err, ShouldBeNil)
...@@ -293,7 +294,8 @@ func TestUserDataAccess(t *testing.T) { ...@@ -293,7 +294,8 @@ func TestUserDataAccess(t *testing.T) {
err := BatchDisableUsers(&disableCmd) err := BatchDisableUsers(&disableCmd)
So(err, ShouldBeNil) So(err, ShouldBeNil)
query := &models.SearchUsersQuery{IsDisabled: "true"} isDisabled := true
query := &models.SearchUsersQuery{IsDisabled: &isDisabled}
err = SearchUsers(query) err = SearchUsers(query)
So(err, ShouldBeNil) So(err, ShouldBeNil)
...@@ -319,7 +321,8 @@ func TestUserDataAccess(t *testing.T) { ...@@ -319,7 +321,8 @@ func TestUserDataAccess(t *testing.T) {
err := BatchDisableUsers(&disableCmd) err := BatchDisableUsers(&disableCmd)
So(err, ShouldBeNil) So(err, ShouldBeNil)
query := &models.SearchUsersQuery{IsDisabled: "false"} isDisabled := false
query := &models.SearchUsersQuery{IsDisabled: &isDisabled}
err = SearchUsers(query) err = SearchUsers(query)
So(err, ShouldBeNil) So(err, ShouldBeNil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment