Use ID or Where to instead directly use Get when load object from database (#11925) (#11934)

Backport #11925

Use ID or Where to instead directly use Get when load object from database

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2020-06-17 21:53:43 +02:00 committed by GitHub
parent 47a5c8e1f7
commit ecad970a26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 28 deletions

View file

@ -300,7 +300,7 @@ func (source *LoginSource) SSPI() *SSPIConfig {
// CreateLoginSource inserts a LoginSource in the DB if not already
// existing with the given name.
func CreateLoginSource(source *LoginSource) error {
has, err := x.Get(&LoginSource{Name: source.Name})
has, err := x.Where("name=?", source.Name).Exist(new(LoginSource))
if err != nil {
return err
} else if has {