Proper error should be thrown when server group is created with existing name. Fixes #3693

This commit is contained in:
Aditya Toshniwal
2019-01-15 18:38:01 +05:30
committed by Akshay Joshi
parent 7b0c81126c
commit 2a359d9d77
3 changed files with 7 additions and 0 deletions
+1
View File
@@ -9,6 +9,7 @@ for it.
.. toctree:: .. toctree::
release_notes_4_2
release_notes_4_1 release_notes_4_1
release_notes_4_0 release_notes_4_0
release_notes_3_6 release_notes_3_6
+1
View File
@@ -14,4 +14,5 @@ Features
Bug fixes Bug fixes
********* *********
| `Bug #3693 <https://redmine.postgresql.org/issues/3693>`_ - Proper error should be thrown when server group is created with existing name.
| `Bug #3695 <https://redmine.postgresql.org/issues/3695>`_ - Ensure long string should be wrap in alertify dialogs. | `Bug #3695 <https://redmine.postgresql.org/issues/3695>`_ - Ensure long string should be wrap in alertify dialogs.
@@ -145,6 +145,7 @@ class ServerGroupView(NodeView):
db.session.delete(sg) db.session.delete(sg)
db.session.commit() db.session.commit()
except Exception as e: except Exception as e:
db.session.rollback()
return make_json_response( return make_json_response(
status=410, success=0, errormsg=e.message status=410, success=0, errormsg=e.message
) )
@@ -178,10 +179,12 @@ class ServerGroupView(NodeView):
servergroup.name = data[u'name'] servergroup.name = data[u'name']
db.session.commit() db.session.commit()
except exc.IntegrityError: except exc.IntegrityError:
db.session.rollback()
return bad_request(gettext( return bad_request(gettext(
"The specified server group already exists." "The specified server group already exists."
)) ))
except Exception as e: except Exception as e:
db.session.rollback()
return make_json_response( return make_json_response(
status=410, success=0, errormsg=e.message status=410, success=0, errormsg=e.message
) )
@@ -251,11 +254,13 @@ class ServerGroupView(NodeView):
) )
) )
except exc.IntegrityError: except exc.IntegrityError:
db.session.rollback()
return bad_request(gettext( return bad_request(gettext(
"The specified server group already exists." "The specified server group already exists."
)) ))
except Exception as e: except Exception as e:
db.session.rollback()
return make_json_response( return make_json_response(
status=410, status=410,
success=0, success=0,