public inbox for [email protected]  
help / color / mirror / Atom feed
From: Aditya Toshniwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][RM3693] Message "Error saving properties Click on Detail" displayed if user create server group with same name
Date: Tue, 15 Jan 2019 11:20:34 +0530
Message-ID: <CAM9w-_kVcupfS=a_-B-T_ncqreiGwmRWwXKGA3j_9gYSnB4XAA@mail.gmail.com> (raw)

Hi Hackers,

Attached is the patch to fix back end exception which is common and
mentioned in SQLAlchemy FAQ -
https://docs.sqlalchemy.org/en/latest/faq/sessions.html#this-session-s-transaction-has-been-rolled-b...
The fix is as per the FAQ answer.

Kindly review.

-- 
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"


Attachments:

  [application/octet-stream] RM3693.patch (1.6K, 3-RM3693.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/__init__.py b/web/pgadmin/browser/server_groups/__init__.py
index 5b80eefc..25addfd0 100644
--- a/web/pgadmin/browser/server_groups/__init__.py
+++ b/web/pgadmin/browser/server_groups/__init__.py
@@ -145,6 +145,7 @@ class ServerGroupView(NodeView):
                 db.session.delete(sg)
                 db.session.commit()
             except Exception as e:
+                db.session.rollback()
                 return make_json_response(
                     status=410, success=0, errormsg=e.message
                 )
@@ -178,10 +179,12 @@ class ServerGroupView(NodeView):
                     servergroup.name = data[u'name']
                 db.session.commit()
             except exc.IntegrityError:
+                db.session.rollback()
                 return bad_request(gettext(
                     "The specified server group already exists."
                 ))
             except Exception as e:
+                db.session.rollback()
                 return make_json_response(
                     status=410, success=0, errormsg=e.message
                 )
@@ -251,11 +254,13 @@ class ServerGroupView(NodeView):
                     )
                 )
             except exc.IntegrityError:
+                db.session.rollback()
                 return bad_request(gettext(
                     "The specified server group already exists."
                 ))
 
             except Exception as e:
+                db.session.rollback()
                 return make_json_response(
                     status=410,
                     success=0,


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin4][RM3693] Message "Error saving properties Click on Detail" displayed if user create server group with same name
  In-Reply-To: <CAM9w-_kVcupfS=a_-B-T_ncqreiGwmRWwXKGA3j_9gYSnB4XAA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox