Fix reverse engineering SQL issue for partitions when specifying digits as comments. Fixes #4893.

pull/27/head
Akshay Joshi 2019-12-05 12:55:52 +05:30
parent 6c7fe644e5
commit f8e1973bc2
3 changed files with 17 additions and 3 deletions

View File

@ -34,6 +34,7 @@ Bug fixes
| `Issue #4818 <https://redmine.postgresql.org/issues/4818>`_ - Fix server connection drops out issue in query tool.
| `Issue #4836 <https://redmine.postgresql.org/issues/4836>`_ - Updated the json file name from 'servers.json' to 'pgadmin4/servers.json' in the container deployment section of the documentation.
| `Issue #4878 <https://redmine.postgresql.org/issues/4878>`_ - Ensure that the superuser should be able to create role, as the superuser overrides all the access restrictions.
| `Issue #4893 <https://redmine.postgresql.org/issues/4893>`_ - Fix reverse engineering SQL issue for partitions when specifying digits as comments.
| `Issue #4923 <https://redmine.postgresql.org/issues/4923>`_ - Enhance the logic to change the label from 'Delete/Drop' to 'Remove' for the server and server group node.
| `Issue #4925 <https://redmine.postgresql.org/issues/4925>`_ - Shown some text on process watcher till the initial logs are loaded.
| `Issue #4926 <https://redmine.postgresql.org/issues/4926>`_ - Fix VPN network disconnect issue where pgAdmin4 hangs on expanding the Servers node.

View File

@ -501,7 +501,12 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings):
data = dict()
for k, v in request.args.items():
try:
data[k] = json.loads(v, encoding='utf-8')
# comments should be taken as is because if user enters a
# json comment it is parsed by loads which should not happen
if k in ('description',):
data[k] = v
else:
data[k] = json.loads(v, encoding='utf-8')
except (ValueError, TypeError, KeyError):
data[k] = v
@ -543,7 +548,12 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
# comments should be taken as is because if user enters a
# json comment it is parsed by loads which should not happen
if k in ('description',):
data[k] = v
else:
data[k] = json.loads(v, encoding='utf-8')
except (ValueError, TypeError, KeyError):
data[k] = v

View File

@ -15,6 +15,8 @@ from pgadmin.utils.ajax import internal_server_error
from pgadmin.utils.exception import ObjectGone
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
import trigger_definition
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.driver import get_driver
from functools import wraps
@ -121,9 +123,10 @@ def get_trigger_function_and_columns(conn, data, tid,
data['tfunction'] = result['rows'][0]['tfunctions']
if len(data['custom_tgargs']) > 0:
driver = get_driver(PG_DEFAULT_DRIVER)
# We know that trigger has more than 1 argument, let's join them
# and convert it to string
formatted_args = ["'{0}'".format(arg)
formatted_args = [driver.qtLiteral(arg)
for arg in data['custom_tgargs']]
formatted_args = ', '.join(formatted_args)