@@ -137,29 +137,31 @@ func (api *API) patchOrganization(rw http.ResponseWriter, r *http.Request) {
137
137
return
138
138
}
139
139
140
- if req .Name == codersdk .DefaultOrganization && ! organization .IsDefault {
141
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
142
- Message : fmt .Sprintf ("Organization name %q is reserved." , codersdk .DefaultOrganization ),
143
- })
144
- return
145
- }
140
+ if req .Name != organization .Name {
141
+ if req .Name == codersdk .DefaultOrganization && ! organization .IsDefault {
142
+ httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
143
+ Message : fmt .Sprintf ("Organization name %q is reserved." , codersdk .DefaultOrganization ),
144
+ })
145
+ return
146
+ }
146
147
147
- _ , err := api .Database .GetOrganizationByName (ctx , req .Name )
148
- if err == nil {
149
- httpapi .Write (ctx , rw , http .StatusConflict , codersdk.Response {
150
- Message : "Organization already exists with that name." ,
151
- })
152
- return
153
- }
154
- if ! errors .Is (err , sql .ErrNoRows ) {
155
- httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
156
- Message : fmt .Sprintf ("Internal error fetching organization %q." , req .Name ),
157
- Detail : err .Error (),
158
- })
159
- return
148
+ _ , err := api .Database .GetOrganizationByName (ctx , req .Name )
149
+ if err == nil {
150
+ httpapi .Write (ctx , rw , http .StatusConflict , codersdk.Response {
151
+ Message : "Organization already exists with that name." ,
152
+ })
153
+ return
154
+ }
155
+ if ! errors .Is (err , sql .ErrNoRows ) {
156
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
157
+ Message : fmt .Sprintf ("Internal error fetching organization %q." , req .Name ),
158
+ Detail : err .Error (),
159
+ })
160
+ return
161
+ }
160
162
}
161
163
162
- organization , err = api .Database .UpdateOrganization (ctx , database.UpdateOrganizationParams {
164
+ organization , err : = api .Database .UpdateOrganization (ctx , database.UpdateOrganizationParams {
163
165
ID : organization .ID ,
164
166
UpdatedAt : dbtime .Now (),
165
167
Name : req .Name ,
0 commit comments