mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix reverse engineering SQL issue for partitions when specifying digits as comments. Fixes #4893.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user