Skip to content

Commit

Permalink
fix(fct_getcolumnsfromid): fix exception when reloadfields is wrong c…
Browse files Browse the repository at this point in the history
…onfigured, using getmessage instead of deprecated method
  • Loading branch information
albertbofill committed Aug 27, 2024
1 parent cb9eb56 commit 34e6208
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
3 changes: 3 additions & 0 deletions updates/36/36012/utils/dml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,6 @@ VALUES('config_style', 'Catalog of different style context', 'role_basic', NULL,

INSERT INTO config_param_system ("parameter", value, descript, "label", isenabled, project_type, "datatype", widgettype)
VALUES('qgis_layers_symbology', '{"styleconfig_vdef":101}', 'Variable to configure parameters related with layer symbology tool', 'Layers symbology', false, 'utils', 'json', 'text');

INSERT INTO sys_message (id, error_message, hint_message, log_level, show_user, project_type, "source")
VALUES(3264, 'Wrong configuration. Check config_form_fields on column widgetcontrol key ''reloadfields'' for columnname:', null, 2, true, 'utils', 'core') ON CONFLICT (id) DO NOTHING;
16 changes: 4 additions & 12 deletions utils/fct/gw_fct_getcolumnsfromid.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ SELECT SCHEMA_NAME.gw_fct_getcolumnsfrom_id($${
DECLARE

v_fields json;
v_childs text;
v_json json;
v_fields_array text[];
v_field text;
v_json_array json[];
Expand All @@ -35,9 +33,7 @@ i integer = 0;
v_fieldsreload text;
v_result text;
v_exists text;
v_message text;
v_parentname text;
v_parentid integer;
v_featureType text;
v_iseditable boolean;

Expand All @@ -60,11 +56,11 @@ BEGIN
v_parentname =((p_data ->>'feature')::json->>'parentField')::text;

SELECT ARRAY(SELECT json_array_elements((replace(v_fieldsreload, '''','"'))::json))
FROM config_form_fields LIMIT 1 INTO v_fields_array;
INTO v_fields_array;

FOREACH v_field IN array v_fields_array
LOOP
EXECUTE 'SELECT column_name FROM information_schema.columns WHERE table_name='''||v_tablename||''' and column_name='''|| replace(v_field, '"','') ||''' LIMIT 1' INTO v_exists;
EXECUTE 'SELECT column_name FROM information_schema.columns WHERE table_name='''||v_tablename||''' and column_name='''|| replace(v_field, '"','') ||''' LIMIT 1' INTO v_exists;
v_json_array[i] := gw_fct_json_object_set_key(v_json_array[i], 'widgetname', 'tab_data_' || replace(v_field, '"',''));
IF v_exists is not null THEN
EXECUTE 'SELECT LOWER(feature_type) FROM cat_feature WHERE child_layer = '''||v_tablename||'''' INTO v_featureType;
Expand All @@ -74,12 +70,8 @@ BEGIN
v_json_array[i] := gw_fct_json_object_set_key(v_json_array[i], 'iseditable', v_iseditable);
i = i+1;
ELSE
EXECUTE 'SELECT id FROM config_form_fields WHERE formname ='''||v_tablename||''' AND columnname = '''||v_parentname||'''' INTO v_parentid;
v_message := 'API is bad configurated. Check column ''reloadfields'' for parameter '''|| v_parentname ||''' with id -> '''||v_parentid||''' on config_form_fields';
v_result := '{"level":0, "text":"'||v_message||'"}';
v_json_array[i] := gw_fct_json_object_set_key(v_json_array[i], 'value', ''::text);
v_json_array[i] := gw_fct_json_object_set_key(v_json_array[i], 'message', v_result::json);
i = i+1;
EXECUTE 'SELECT gw_fct_getmessage($${"client":{"device":4, "infoType":1, "lang":"ES"},"feature":{},
"data":{"message":"3264", "function":"2874","debug_msg":"'||v_parentname||'", "is_process":true}}$$);';
END IF;
END LOOP;

Expand Down

0 comments on commit 34e6208

Please sign in to comment.