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

This commit is contained in:
Oleg Gaidarenko
2019-07-17 06:24:56 +03:00
committed by GitHub
parent c194ae1ba5
commit d9f01cb822
3 changed files with 9 additions and 13 deletions
+2 -7
View File
@@ -456,14 +456,9 @@ func SearchUsers(query *models.SearchUsersQuery) error {
whereParams = append(whereParams, queryWithWildcards, queryWithWildcards, queryWithWildcards)
}
if query.IsDisabled != "" {
param, err := strconv.ParseBool(query.IsDisabled)
if err != nil {
return err
}
if query.IsDisabled != nil {
whereConditions = append(whereConditions, "is_disabled = ?")
whereParams = append(whereParams, param)
whereParams = append(whereParams, query.IsDisabled)
}
if query.AuthModule != "" {
+6 -3
View File
@@ -194,7 +194,8 @@ func TestUserDataAccess(t *testing.T) {
}
})
query := models.SearchUsersQuery{IsDisabled: "false"}
isDisabled := false
query := models.SearchUsersQuery{IsDisabled: &isDisabled}
err := SearchUsers(&query)
So(err, ShouldBeNil)
@@ -293,7 +294,8 @@ func TestUserDataAccess(t *testing.T) {
err := BatchDisableUsers(&disableCmd)
So(err, ShouldBeNil)
query := &models.SearchUsersQuery{IsDisabled: "true"}
isDisabled := true
query := &models.SearchUsersQuery{IsDisabled: &isDisabled}
err = SearchUsers(query)
So(err, ShouldBeNil)
@@ -319,7 +321,8 @@ func TestUserDataAccess(t *testing.T) {
err := BatchDisableUsers(&disableCmd)
So(err, ShouldBeNil)
query := &models.SearchUsersQuery{IsDisabled: "false"}
isDisabled := false
query := &models.SearchUsersQuery{IsDisabled: &isDisabled}
err = SearchUsers(query)
So(err, ShouldBeNil)