Skip to content

Commit b07eafa

Browse files
committed
Fixed an issue on type casting of default string function/procedure arguments in debugger tool. #9036
1 parent dd51290 commit b07eafa

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

docs/en_US/release_notes_9_11.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Bug fixes
3636
| `Issue #9297 <https://github.com/pgadmin-org/pgadmin4/issues/9297>`_ - Fixed an issue where EXPLAIN should run on query under cursor if no text is selected.
3737
| `Issue #9351 <https://github.com/pgadmin-org/pgadmin4/issues/9351>`_ - Fixed an issue where opening file in Query Tool does not retain file name in tab.
3838
| `Issue #9354 <https://github.com/pgadmin-org/pgadmin4/issues/9354>`_ - Fixed an issue where connection is failing via Query Tool/PSQL Tool workspaces.
39-
| `Issue #9354 <https://github.com/pgadmin-org/pgadmin4/issues/9354>`_ - Fixed an issue where connection is failing via Query Tool/PSQL Tool workspaces.
4039
| `Issue #9372 <https://github.com/pgadmin-org/pgadmin4/issues/9372>`_ - Fixed an issue where copying highlighted text in the query tool data output cell editor would copy the complete string.
4140
| `Issue #9373 <https://github.com/pgadmin-org/pgadmin4/issues/9373>`_ - Fixed an issue where copying a single cell should not add quoting.
4241
| `Issue #9408 <https://github.com/pgadmin-org/pgadmin4/issues/9408>`_ - Ensure the proper handling of extra volume mount configurations in the Helm deployment template by correcting the configuration value references.
42+
| `Issue #9036 <https://github.com/pgadmin-org/pgadmin4/issues/9036>`_ - Fixed an issue on type casting of default string function/procedure arguments in debugger tool.

web/pgadmin/tools/debugger/__init__.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,37 @@ def get_search_path(conn):
785785
return True, res
786786

787787

788+
def filter_params_by_default(params_list, default_value_str):
789+
"""
790+
Truncate params_list at the first index where the param matches the
791+
default value. If any subsequent param is present after default,
792+
error is raised.
793+
:param params_list:
794+
:param default_value_str:
795+
:return:
796+
"""
797+
default_values = []
798+
if default_value_str:
799+
# Split at comma, strip spaces, and add a space after index 0
800+
raw_defaults = str(default_value_str).split(',')
801+
default_values = [
802+
v.strip() if i == 0 else ' ' + v.strip()
803+
for i, v in enumerate(raw_defaults)
804+
]
805+
# Check for default value usage and subsequent params
806+
for idx, param in enumerate(params_list):
807+
if (idx < len(default_values) and str(param.get('value', '')) ==
808+
default_values[idx]):
809+
# If any subsequent param is present after default, error
810+
if any(str(p.get('value', '')) != default_values[i] for i, p in
811+
enumerate(params_list[idx + 1:], start=idx + 1)):
812+
return (None,
813+
gettext("Once a default value is passed, no "
814+
"subsequent arguments should be provided."))
815+
return params_list[:idx], None
816+
return params_list, None
817+
818+
788819
@blueprint.route(
789820
'/initialize_target/<debug_type>/<int:trans_id>/<int:sid>/<int:did>/'
790821
'<int:scid>/<int:func_id>',
@@ -870,9 +901,17 @@ def initialize_target(debug_type, trans_id, sid, did,
870901
# provide the data from another session so below condition will
871902
# be be required
872903
if request.data:
873-
de_inst.function_data['args_value'] = \
874-
json.loads(request.data)
875-
904+
params_list = json.loads(request.data)
905+
try:
906+
params_list, error_msg = filter_params_by_default(
907+
params_list,
908+
de_inst.function_data['default_value']
909+
)
910+
if error_msg:
911+
return internal_server_error(errormsg=error_msg)
912+
except Exception as e:
913+
return internal_server_error(errormsg=str(e))
914+
de_inst.function_data['args_value'] = params_list
876915
# Update the debugger data session variable
877916
# Here frame_id is required when user debug the multilevel function.
878917
# When user select the frame from client we need to update the frame

0 commit comments

Comments
 (0)