Ensure previous notices are not removed from the Messages tab in the Query Tool if an error occurs during query execution. Fixes #3016

This commit is contained in:
Akshay Joshi 2018-11-14 08:27:47 -05:00 committed by Dave Page
parent 29ed7ec881
commit eae18f6f14
2 changed files with 22 additions and 3 deletions

View File

@ -15,5 +15,6 @@ Features
Bug fixes
*********
| `Bug #3016 <https://redmine.postgresql.org/issues/3016>`_ - Ensure previous notices are not removed from the Messages tab in the Query Tool if an error occurs during query execution.
| `Bug #3029 <https://redmine.postgresql.org/issues/3029>`_ - Allow the selection order to be preserved in the Select2 control to fix column ordering in data Import/Export.
| `Bug #3629 <https://redmine.postgresql.org/issues/3629>`_ - Allow use of 0 (integer) and empty strings as parameters in the debugger.
| `Bug #3629 <https://redmine.postgresql.org/issues/3629>`_ - Allow use of 0 (integer) and empty strings as parameters in the debugger.

View File

@ -1685,7 +1685,8 @@ Failed to reset the connection to the server due to following error:
# if formatted_msg is false then return from the function
if not formatted_msg:
return errmsg
notices = self.get_notices()
return errmsg if notices is '' else notices + '\n' + errmsg
# Do not append if error starts with `ERROR:` as most pg related
# error starts with `ERROR:`
@ -1748,7 +1749,8 @@ Failed to reset the connection to the server due to following error:
errmsg += gettext('Context: ')
errmsg += self.decode_to_utf8(exception_obj.diag.context)
return errmsg
notices = self.get_notices()
return errmsg if notices is '' else notices + '\n' + errmsg
#####
# As per issue reported on pgsycopg2 github repository link is shared below
@ -1827,6 +1829,22 @@ Failed to reset the connection to the server due to following error:
]
return notifies
def get_notices(self):
"""
This function will returns the notices as string.
:return:
"""
notices = ''
# Check for notices.
if self.conn.notices and self.__notices is not None:
self.__notices.extend(self.conn.notices)
self.conn.notices.clear()
while self.__notices:
notices += self.__notices.pop(0)
return notices
def pq_encrypt_password_conn(self, password, user):
"""
This function will return the encrypted password for database server