From 5b435cdf9313c26d46a7dbb74ef951e910367bc0 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Wed, 18 Sep 2024 20:08:01 +0530 Subject: [PATCH] Enabled 'Strict' control for EPAS >= 95 --- .../functions/static/js/function.ui.js | 52 ++++++++++--------- .../js/SchemaView/hooks/useFieldError.js | 4 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js index 2168d5b7c1a..f8bae59da1c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js @@ -159,33 +159,21 @@ export default class FunctionSchema extends BaseUISchema { } } - isGreaterThan95(state){ - if ( + isLessThan95ORNonSPL(state) { + return ( + this.inCatalog() || this.node_info['node_info'].server.version < 90500 || this.node_info['node_info']['server'].server_type != 'ppas' || state.lanname != 'edbspl' - ) { - state.provolatile = null; - state.proisstrict = false; - state.procost = null; - state.proleakproof = false; - return true; - } else { - return false; - } + ); } - isGreaterThan96(state){ - if ( + isLessThan96ORNonSPL(state){ + return ( this.node_info['node_info'].server.version < 90600 || this.node_info['node_info']['server'].server_type != 'ppas' || state.lanname != 'edbspl' - ) { - state.proparallel = null; - return true; - } else { - return false; - } + ); } @@ -210,7 +198,7 @@ export default class FunctionSchema extends BaseUISchema { if (this.type !== 'procedure') { obj.inCatalog(state); } else { - obj.isGreaterThan95(state); + obj.isLessThan95ORNonSPL(state); } }, noEmpty: true, @@ -328,7 +316,7 @@ export default class FunctionSchema extends BaseUISchema { {'label': 'VOLATILE', 'value': 'v'}, {'label': 'STABLE', 'value': 's'}, {'label': 'IMMUTABLE', 'value': 'i'}, - ], disabled: (this.type !== 'procedure') ? obj.inCatalog() : obj.isGreaterThan95, + ], disabled: (this.type !== 'procedure') ? obj.inCatalog() : obj.isLessThan95ORNonSPL, controlProps: {allowClear: false}, },{ id: 'proretset', label: gettext('Returns a set?'), type: 'switch', @@ -336,8 +324,22 @@ export default class FunctionSchema extends BaseUISchema { visible: obj.isVisible, readonly: obj.isReadonly, },{ id: 'proisstrict', label: gettext('Strict?'), type: 'switch', - group: gettext('Options'), disabled: obj.inCatalog(), + group: gettext('Options'), + disabled: obj.inCatalog() ? true : obj.isLessThan95ORNonSPL, deps: ['lanname'], + depChange: (state, source) => ( + (source[source.length - 1] !== 'lanname') ? undefined : ( + obj.isLessThan95ORNonSPL(state) + ) ? { + provolatile: null, + proisstrict: false, + procost: null, + proleakproof: false, + proparallel: null, + } : ( + obj.isLessThan95ORNonSPL(state) ? { proparallel: null } : undefined + ) + ), },{ id: 'prosecdef', label: gettext('Security of definer?'), group: gettext('Options'), type: 'switch', @@ -357,13 +359,13 @@ export default class FunctionSchema extends BaseUISchema { {'label': 'RESTRICTED', 'value': 'r'}, {'label': 'SAFE', 'value': 's'}, ], - disabled: (this.type !== 'procedure') ? obj.inCatalog(): obj.isGreaterThan96, + disabled: (this.type !== 'procedure') ? obj.inCatalog(): obj.isLessThan96ORNonSPL, min_version: 90600, controlProps: {allowClear: false}, },{ id: 'procost', label: gettext('Estimated cost'), group: gettext('Options'), cell:'string', type: 'text', deps: ['lanname'], - disabled: (this.type !== 'procedure') ? obj.isDisabled: obj.isGreaterThan95, + disabled: (this.type !== 'procedure') ? obj.isDisabled : obj.isLessThan95ORNonSPL, },{ id: 'prorows', label: gettext('Estimated rows'), type: 'text', deps: ['proretset'], visible: obj.isVisible, @@ -378,7 +380,7 @@ export default class FunctionSchema extends BaseUISchema { },{ id: 'proleakproof', label: gettext('Leak proof?'), group: gettext('Options'), cell:'boolean', type: 'switch', min_version: 90200, - disabled: (this.type !== 'procedure') ? obj.inCatalog(): obj.isGreaterThan95, + disabled: (this.type !== 'procedure') ? obj.inCatalog() : obj.isLessThan95ORNonSPL, deps: ['lanname'], },{ id: 'prosupportfunc', label: gettext('Support function'), diff --git a/web/pgadmin/static/js/SchemaView/hooks/useFieldError.js b/web/pgadmin/static/js/SchemaView/hooks/useFieldError.js index 27442337a56..6b8c21ae9ca 100644 --- a/web/pgadmin/static/js/SchemaView/hooks/useFieldError.js +++ b/web/pgadmin/static/js/SchemaView/hooks/useFieldError.js @@ -9,9 +9,7 @@ import { useEffect } from 'react'; -const convertKeysToString = (arr) => { - return (arr||[]).map((key) => String(key)) -}; +const convertKeysToString = (arr) => (arr||[]).map((key) => String(key)); const isPathEqual = (path1, path2) => ( Array.isArray(path1) && Array.isArray(path2) &&