From a961afe52bf94f71e917e05e366a4b71834a2e84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E1=B4=9C=C9=B4=E1=B4=8B=C9=B4=E1=B4=A1=E1=B4=8F=C9=B4?=
 <u@gogs.io>
Date: Sun, 16 Aug 2020 21:31:08 +0800
Subject: [PATCH] db: fix update team panic (#6253)

* db: fix update team panic

* Update CHANGELOG
---
 CHANGELOG.md                | 1 +
 internal/context/context.go | 2 +-
 internal/db/org_team.go     | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8477051b9..2a7ce2b7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,7 @@ All notable changes to Gogs are documented in this file.
 - Private repositories are hidden in the organization's view. [#5869](https://github.com/gogs/gogs/issues/5869)
 - Server error when changing email address in user settings page. [#5899](https://github.com/gogs/gogs/issues/5899)
 - Fall back to use RFC 3339 as time layout when misconfigured. [#6098](https://github.com/gogs/gogs/issues/6098)
+- Unable to update team with server error. [#6185](https://github.com/gogs/gogs/issues/6185)
 - Webhooks are not fired after push when `[service] REQUIRE_SIGNIN_VIEW = true`.
 
 ### Removed
diff --git a/internal/context/context.go b/internal/context/context.go
index a34398a21..d05767ba4 100644
--- a/internal/context/context.go
+++ b/internal/context/context.go
@@ -179,7 +179,7 @@ func (c *Context) NotFound() {
 
 // Error renders the 500 page.
 func (c *Context) Error(err error, msg string) {
-	log.ErrorDepth(5, "%s: %v", msg, err)
+	log.ErrorDepth(4, "%s: %v", msg, err)
 
 	c.Title("status.internal_server_error")
 
diff --git a/internal/db/org_team.go b/internal/db/org_team.go
index 9daca9e79..b2d6fd562 100644
--- a/internal/db/org_team.go
+++ b/internal/db/org_team.go
@@ -348,7 +348,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) {
 
 	t.LowerName = strings.ToLower(t.Name)
 	existingTeam := new(Team)
-	has, err := x.Where("org_id=?", t.OrgID).And("lower_name=?", t.LowerName).And("id!=?", t.ID).Get(&existingTeam)
+	has, err := x.Where("org_id=?", t.OrgID).And("lower_name=?", t.LowerName).And("id!=?", t.ID).Get(existingTeam)
 	if err != nil {
 		return err
 	} else if has {