From 251bf0569217279e29e3170684b024cc429b6312 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 12 Jun 2023 18:44:31 +0530 Subject: [PATCH] Fixed the following SonarQube code smells: 1) Do not use Array index in keys. 2) Unnecessary escape character. 3) Rename this local variable to match the regular expression ^[_a-z][a-z0-9_]*$ 4) Remove the unused local variable. --- docs/en_US/release_notes.rst | 1 + docs/en_US/release_notes_7_4.rst | 32 +++++++++++ .../schemas/tables/triggers/__init__.py | 1 - .../static/js/quick_search/trigger_search.js | 4 +- web/pgadmin/dashboard/static/js/Dashboard.jsx | 10 ++-- .../bgprocess/static/js/ProcessDetails.jsx | 3 +- .../misc/cloud/static/js/aws_schema.ui.js | 2 +- .../misc/cloud/static/js/cloud_components.jsx | 2 +- web/pgadmin/misc/file_manager/__init__.py | 56 +++++++++---------- .../static/js/components/GridView.jsx | 4 +- web/pgadmin/static/js/AppMenuBar.jsx | 9 ++- web/pgadmin/static/js/Explain/Analysis.jsx | 4 +- .../static/js/SchemaView/DataGridView.jsx | 2 +- .../js/components/ObjectBreadcrumbs.jsx | 5 +- .../static/js/components/ShortcutTitle.jsx | 4 +- web/pgadmin/tools/import_export/__init__.py | 1 - .../static/js/import_export.ui.js | 10 ++-- .../tools/import_export_servers/__init__.py | 3 - .../tools/psql/static/js/psql_module.js | 2 - web/pgadmin/tools/restore/__init__.py | 2 +- web/pgadmin/tools/schema_diff/__init__.py | 2 + .../tools/schema_diff/directory_compare.py | 1 - web/pgadmin/tools/sqleditor/__init__.py | 21 ++++--- .../js/components/sections/MainToolBar.jsx | 4 +- .../js/components/sections/Notifications.jsx | 4 +- .../utils/apply_explain_plan_wrapper.py | 2 - web/pgadmin/utils/__init__.py | 26 ++++----- .../utils/driver/psycopg3/connection.py | 15 ++--- .../utils/driver/psycopg3/server_manager.py | 4 +- web/pgadmin/utils/paths.py | 16 +++--- .../feature_tests/query_tool_tests.py | 1 - 31 files changed, 136 insertions(+), 117 deletions(-) create mode 100644 docs/en_US/release_notes_7_4.rst diff --git a/docs/en_US/release_notes.rst b/docs/en_US/release_notes.rst index 9de7e7ec5..9fbe553f5 100644 --- a/docs/en_US/release_notes.rst +++ b/docs/en_US/release_notes.rst @@ -11,6 +11,7 @@ notes for it. .. toctree:: :maxdepth: 1 + release_notes_7_4 release_notes_7_3 release_notes_7_2 release_notes_7_1 diff --git a/docs/en_US/release_notes_7_4.rst b/docs/en_US/release_notes_7_4.rst new file mode 100644 index 000000000..64a5ce5e3 --- /dev/null +++ b/docs/en_US/release_notes_7_4.rst @@ -0,0 +1,32 @@ +*********** +Version 7.4 +*********** + +Release date: 2023-06-29 + +This release contains a number of bug fixes and new features since the release of pgAdmin 4 v7.3. + +Supported Database Servers +************************** +**PostgreSQL**: 11, 12, 13, 14 and 15 + +**EDB Advanced Server**: 11, 12, 13, 14 and 15 + +Bundled PostgreSQL Utilities +**************************** +**psql**, **pg_dump**, **pg_dumpall**, **pg_restore**: 15.3 + + +New features +************ + + +Housekeeping +************ + + +Bug fixes +********* + + | `Issue #6065 `_ - Ensure that query tool shortcuts are working properly. + | `Issue #6363 `_ - Fixed an issue where preview images for themes were not loading. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py index aac16fcda..61ca51c8c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py @@ -359,7 +359,6 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare): """ res = [{'label': '', 'value': ''}] - # TODO: REMOVE True Condition , it's just for testing # If server type is EDB-PPAS then we also need to add # inline edb-spl along with options fetched by below sql diff --git a/web/pgadmin/browser/static/js/quick_search/trigger_search.js b/web/pgadmin/browser/static/js/quick_search/trigger_search.js index cb9154990..8094f1646 100644 --- a/web/pgadmin/browser/static/js/quick_search/trigger_search.js +++ b/web/pgadmin/browser/static/js/quick_search/trigger_search.js @@ -133,7 +133,7 @@ export function Search({closeModal}) { let menuItemsHtmlElement = []; items.forEach((i) => { menuItemsHtmlElement.push( -
  • { closeModal(); i.callback(); @@ -257,7 +257,7 @@ export function Search({closeModal}) { {Object.keys(helpSearchResult.data).map( (value, index) => { - if(index <= 9) { return
  • {value}
  • ; } + if(index <= 9) { return
  • {value}
  • ; } })} {(Object.keys(helpSearchResult.data).length == 0) ? (
    {gettext('No search results')}
    ):''} diff --git a/web/pgadmin/dashboard/static/js/Dashboard.jsx b/web/pgadmin/dashboard/static/js/Dashboard.jsx index 3d4dcbde9..7194fcc10 100644 --- a/web/pgadmin/dashboard/static/js/Dashboard.jsx +++ b/web/pgadmin/dashboard/static/js/Dashboard.jsx @@ -861,7 +861,7 @@ export default function Dashboard({ controlProps={CustomActiveOnlyHeaderLabel} >); }; - + return ( <> {sid && props.serverConnected ? ( @@ -890,8 +890,8 @@ export default function Dashboard({ value={tabVal} onChange={tabChanged} > - {tabs.map((tabValue, i) => { - return ; + {tabs.map((tabValue) => { + return ; })} @@ -961,8 +961,8 @@ export function ChartContainer(props) {
    {props.title}
    - {props.datasets?.map((datum, i)=>( -
    + {props.datasets?.map((datum)=>( +
         {datum.label}
    diff --git a/web/pgadmin/misc/bgprocess/static/js/ProcessDetails.jsx b/web/pgadmin/misc/bgprocess/static/js/ProcessDetails.jsx index c6284521d..78a00e02a 100644 --- a/web/pgadmin/misc/bgprocess/static/js/ProcessDetails.jsx +++ b/web/pgadmin/misc/bgprocess/static/js/ProcessDetails.jsx @@ -175,11 +175,12 @@ export default function ProcessDetails({data}) { {logs == null && {gettext('Loading process logs...')}} {logs?.length == 0 && gettext('No logs available.')} {logs?.map((log, i)=>{ + let id = logs.length-i; return
    { if(i==logs.length-1) { el?.scrollIntoView(); } - }} key={i} className={errRe.test(log) ? classes.logErr : ''}>{log}
    ; + }} key={id} className={errRe.test(log) ? classes.logErr : ''}>{log}
    ; })} diff --git a/web/pgadmin/misc/cloud/static/js/aws_schema.ui.js b/web/pgadmin/misc/cloud/static/js/aws_schema.ui.js index 0358262f5..a540243af 100644 --- a/web/pgadmin/misc/cloud/static/js/aws_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/aws_schema.ui.js @@ -166,7 +166,7 @@ class DatabaseSchema extends BaseUISchema { }, { id: 'db_password', label: gettext('Password'), type: 'password', mode: ['create'], noEmpty: true, - helpMessage: gettext('At least 8 printable ASCII characters. Cannot contain any of the following: / \(slash\), \'\(single quote\), "\(double quote\) and @ \(at sign\).') + helpMessage: gettext('At least 8 printable ASCII characters. Cannot contain any of the following: / (slash), \'(single quote), "(double quote) and @ (at sign).') }, { id: 'db_confirm_password', label: gettext('Confirm password'), type: 'password', diff --git a/web/pgadmin/misc/cloud/static/js/cloud_components.jsx b/web/pgadmin/misc/cloud/static/js/cloud_components.jsx index 7b5edab22..ae8193e12 100644 --- a/web/pgadmin/misc/cloud/static/js/cloud_components.jsx +++ b/web/pgadmin/misc/cloud/static/js/cloud_components.jsx @@ -104,7 +104,7 @@ export function FinalSummary(props) { return summary.map((item, index) => { return ( - +
    {gettext(summaryHeader[index])} diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py index aaa428a1e..f02dd45ed 100644 --- a/web/pgadmin/misc/file_manager/__init__.py +++ b/web/pgadmin/misc/file_manager/__init__.py @@ -311,7 +311,7 @@ class Filemanager(): def __init__(self, trans_id, ss=''): self.trans_id = trans_id self.dir = get_storage_directory() - self.sharedDir = get_storage_directory(shared_storage=ss) + self.shared_dir = get_storage_directory(shared_storage=ss) if self.dir is not None and isinstance(self.dir, list): self.dir = "" @@ -409,10 +409,10 @@ class Filemanager(): last_ss_name = blueprint.last_storage.get() if last_ss_name and last_ss_name != MY_STORAGE \ and len(config.SHARED_STORAGE) > 0: - selectedDir = [sdir for sdir in config.SHARED_STORAGE if - sdir['name'] == last_ss_name] - last_ss = selectedDir[0]['path'] if len( - selectedDir) == 1 else storage_dir + selected_dir = [sdir for sdir in config.SHARED_STORAGE if + sdir['name'] == last_ss_name] + last_ss = selected_dir[0]['path'] if len( + selected_dir) == 1 else storage_dir else: if last_ss_name != MY_STORAGE: last_dir = '/' @@ -770,8 +770,8 @@ class Filemanager(): trans_data = Filemanager.get_trasaction_selection(self.trans_id) the_dir = None if config.SERVER_MODE: - if self.sharedDir and len(config.SHARED_STORAGE) > 0: - the_dir = self.sharedDir + if self.shared_dir and len(config.SHARED_STORAGE) > 0: + the_dir = self.shared_dir else: the_dir = self.dir @@ -782,18 +782,16 @@ class Filemanager(): the_dir, path, trans_data, file_type, show_hidden) return filelist - def check_access(self, ss, mode): - if self.sharedDir: - selectedDirList = [sdir for sdir in config.SHARED_STORAGE if - sdir['name'] == ss] - selectedDir = selectedDirList[0] if len( - selectedDirList) == 1 else None + def check_access(self, ss): + if self.shared_dir: + selected_dir_list = [sdir for sdir in config.SHARED_STORAGE if + sdir['name'] == ss] + selected_dir = selected_dir_list[0] if len( + selected_dir_list) == 1 else None - if selectedDir: - if selectedDir[ - 'restricted_access'] and not current_user.has_role( - "Administrator"): - raise PermissionError(ACCESS_DENIED_MESSAGE) + if selected_dir and selected_dir['restricted_access'] and \ + not current_user.has_role("Administrator"): + raise PermissionError(ACCESS_DENIED_MESSAGE) def rename(self, old=None, new=None): """ @@ -802,8 +800,8 @@ class Filemanager(): if not self.validate_request('rename'): return unauthorized(self.ERROR_NOT_ALLOWED['Error']) - if self.sharedDir: - the_dir = self.sharedDir + if self.shared_dir: + the_dir = self.shared_dir else: the_dir = self.dir if self.dir is not None else '' @@ -848,8 +846,8 @@ class Filemanager(): """ if not self.validate_request('delete'): return unauthorized(self.ERROR_NOT_ALLOWED['Error']) - if self.sharedDir: - the_dir = self.sharedDir + if self.shared_dir: + the_dir = self.shared_dir else: the_dir = self.dir if self.dir is not None else '' orig_path = "{0}{1}".format(the_dir, path) @@ -874,8 +872,8 @@ class Filemanager(): if not self.validate_request('upload'): return unauthorized(self.ERROR_NOT_ALLOWED['Error']) - if self.sharedDir: - the_dir = self.sharedDir + if self.shared_dir: + the_dir = self.shared_dir else: the_dir = self.dir if self.dir is not None else '' @@ -1042,8 +1040,8 @@ class Filemanager(): if not self.validate_request('create'): return unauthorized(self.ERROR_NOT_ALLOWED['Error']) - if self.sharedDir and len(config.SHARED_STORAGE) > 0: - user_dir = self.sharedDir + if self.shared_dir and len(config.SHARED_STORAGE) > 0: + user_dir = self.shared_dir else: user_dir = self.dir if self.dir is not None else '' @@ -1073,8 +1071,8 @@ class Filemanager(): if not self.validate_request('download'): return unauthorized(self.ERROR_NOT_ALLOWED['Error']) - if self.sharedDir and len(config.SHARED_STORAGE) > 0: - the_dir = self.sharedDir + if self.shared_dir and len(config.SHARED_STORAGE) > 0: + the_dir = self.shared_dir else: the_dir = self.dir if self.dir is not None else '' @@ -1139,7 +1137,7 @@ def file_manager(trans_id): if ss and mode in ['upload', 'rename', 'delete', 'addfolder', 'add', 'permission']: - my_fm.check_access(ss, mode) + my_fm.check_access(ss) func = getattr(my_fm, mode) try: if mode in ['getfolder', 'download']: diff --git a/web/pgadmin/misc/file_manager/static/js/components/GridView.jsx b/web/pgadmin/misc/file_manager/static/js/components/GridView.jsx index 7bebf347f..9f51f4b56 100644 --- a/web/pgadmin/misc/file_manager/static/js/components/GridView.jsx +++ b/web/pgadmin/misc/file_manager/static/js/components/GridView.jsx @@ -81,7 +81,7 @@ export function ItemView({idx, row, selected, onItemSelect, onItemEnter, onEditC onEditComplete(row); } }; - + let icon = ; if(row.file_type == 'dir') { icon = ; @@ -133,7 +133,7 @@ export default function GridView({items, operation, onItemSelect, onItemEnter})
      {items.map((item, i)=>( - ) )}
    diff --git a/web/pgadmin/static/js/AppMenuBar.jsx b/web/pgadmin/static/js/AppMenuBar.jsx index db2bb0a74..5e5c3cadb 100644 --- a/web/pgadmin/static/js/AppMenuBar.jsx +++ b/web/pgadmin/static/js/AppMenuBar.jsx @@ -1,11 +1,10 @@ import { Box, makeStyles } from '@material-ui/core'; -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { PrimaryButton } from './components/Buttons'; import { PgMenu, PgMenuDivider, PgMenuItem, PgSubMenu } from './components/Menu'; import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown'; import AccountCircleRoundedIcon from '@material-ui/icons/AccountCircleRounded'; import pgAdmin from 'sources/pgadmin'; -import { useEffect } from 'react'; const useStyles = makeStyles((theme)=>({ root: { @@ -96,17 +95,17 @@ export default function AppMenuBar() {
    - {pgAdmin.Browser.MainMenus?.map((menu, i)=>{ + {pgAdmin.Browser.MainMenus?.map((menu)=>{ return ( {menu.label}} + menuButton={{menu.label}} label={menu.label} key={menu.name} > {menu.getMenuItems().map((menuItem, i)=>{ const submenus = menuItem.getMenuItems(); if(submenus) { - return + return {submenus.map((submenuItem, si)=>{ return getPgMenuItem(submenuItem, si); })} diff --git a/web/pgadmin/static/js/Explain/Analysis.jsx b/web/pgadmin/static/js/Explain/Analysis.jsx index 9b396957b..b11935ba3 100644 --- a/web/pgadmin/static/js/Explain/Analysis.jsx +++ b/web/pgadmin/static/js/Explain/Analysis.jsx @@ -195,8 +195,8 @@ export default function Analysis({explainTable}) {
    - {_.sortBy(explainTable.rows,(r)=>r['data']['_serial']).map((row, i)=>{ - return r['data']['_serial']).map((row)=>{ + return {rows.map((row, i) => { prepareRow(row); - return + return diff --git a/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx b/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx index 0212ffb51..ccd02b044 100644 --- a/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx +++ b/web/pgadmin/static/js/components/ObjectBreadcrumbs.jsx @@ -44,7 +44,6 @@ export default function ObjectBreadcrumbs({pgAdmin}) { description: null, }); const onItemHover = (item, _data)=>{ - // if(!checkIsMounted) return; if(item && !_data?._type.startsWith('coll-')) { setObjectData({ path: pgAdmin.Browser.tree.getNodeDisplayPath(item, false), @@ -99,8 +98,8 @@ export default function ObjectBreadcrumbs({pgAdmin}) {
    { - objectData.path?.reduce((res, item, i)=>( - res.concat({item}, ) + objectData.path?.reduce((res, item)=>( + res.concat({item}, ) ), []).slice(0, -1) }
    diff --git a/web/pgadmin/static/js/components/ShortcutTitle.jsx b/web/pgadmin/static/js/components/ShortcutTitle.jsx index 930eddf78..f19f592c9 100644 --- a/web/pgadmin/static/js/components/ShortcutTitle.jsx +++ b/web/pgadmin/static/js/components/ShortcutTitle.jsx @@ -73,8 +73,8 @@ export default function ShortcutTitle({title, shortcut, accesskey}) { <>
    {title}
    - {keys.map((key, i)=>{ - return
    {key}
    ; + {keys.map((key)=>{ + return
    {key}
    ; })}
    diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py index a61543003..5ea62e343 100644 --- a/web/pgadmin/tools/import_export/__init__.py +++ b/web/pgadmin/tools/import_export/__init__.py @@ -99,7 +99,6 @@ class IEMessage(IProcessDesc): if s is None: return _("Not available") - server_str = '{0}'.format(s.name) host_port_str = '' if s.host: host_port_str = '({0}:{1})'.format( diff --git a/web/pgadmin/tools/import_export/static/js/import_export.ui.js b/web/pgadmin/tools/import_export/static/js/import_export.ui.js index df545928b..ce97d98ec 100644 --- a/web/pgadmin/tools/import_export/static/js/import_export.ui.js +++ b/web/pgadmin/tools/import_export/static/js/import_export.ui.js @@ -21,7 +21,7 @@ export default class ImportExportSchema extends BaseUISchema { oid: undefined, header: undefined, delimiter: ',', - quote: '\"', + quote: '"', escape: '\'', file: undefined, format: 'csv', @@ -156,8 +156,8 @@ export default class ImportExportSchema extends BaseUISchema { type: 'select', controlProps: {creatable: true}, options: [{ - 'label': '\"', - 'value': '\"', + 'label': '"', + 'value': '"', }, { 'label': '\'', @@ -174,8 +174,8 @@ export default class ImportExportSchema extends BaseUISchema { type: 'select', controlProps: {creatable: true}, options: [{ - 'label': '\"', - 'value': '\"', + 'label': '"', + 'value': '"', }, { 'label': '\'', diff --git a/web/pgadmin/tools/import_export_servers/__init__.py b/web/pgadmin/tools/import_export_servers/__init__.py index 3aad71007..e6098c473 100644 --- a/web/pgadmin/tools/import_export_servers/__init__.py +++ b/web/pgadmin/tools/import_export_servers/__init__.py @@ -117,9 +117,6 @@ def load_servers(): file_path = unquote(filename) - # retrieve storage directory path - storage_manager_path = get_storage_directory() - try: file_path = filename_with_file_manager_path(file_path) except PermissionError as e: diff --git a/web/pgadmin/tools/psql/static/js/psql_module.js b/web/pgadmin/tools/psql/static/js/psql_module.js index 6af2eabb2..5ce78b473 100644 --- a/web/pgadmin/tools/psql/static/js/psql_module.js +++ b/web/pgadmin/tools/psql/static/js/psql_module.js @@ -228,8 +228,6 @@ export function initialize(gettext, url_for, _, pgAdmin, csrfToken, Browser) { let db_label = ''; if(pData.database && pData.database._id) { db_label = _.escape(pData.database._label.replace('\\', '\\\\')); - db_label = db_label.replace('\'', '\''); - db_label = db_label.replace('"', '\"'); openUrl += `&db=${db_label}`; } else { openUrl += `&db=${''}`; diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py index 950cdd3cc..95fa29c03 100644 --- a/web/pgadmin/tools/restore/__init__.py +++ b/web/pgadmin/tools/restore/__init__.py @@ -253,7 +253,7 @@ def set_multiple(key, param, data, args, driver, conn, with_schema=True): if key in data and \ len(data[key]) > 0: if with_schema: - # TODO:// This is temporary + # This is temporary # Once object tree is implemented then we will use # list of tuples 'else' part _set_value_with_schema(data, key, args, param, driver, conn) diff --git a/web/pgadmin/tools/schema_diff/__init__.py b/web/pgadmin/tools/schema_diff/__init__.py index b9a95d5ab..0f27e3d20 100644 --- a/web/pgadmin/tools/schema_diff/__init__.py +++ b/web/pgadmin/tools/schema_diff/__init__.py @@ -564,6 +564,7 @@ def compare_database(params): msg = gettext("Successfully compare the specified databases.") total_percent = 100 + diff_model_obj.set_comparison_info(msg, total_percent) # Update the message and total percentage done in session object update_session_diff_transaction(params['trans_id'], session_obj, diff_model_obj) @@ -626,6 +627,7 @@ def compare_schema(params): msg = gettext("Successfully compare the specified schemas.") total_percent = 100 + diff_model_obj.set_comparison_info(msg, total_percent) # Update the message and total percentage done in session object update_session_diff_transaction(params['trans_id'], session_obj, diff_model_obj) diff --git a/web/pgadmin/tools/schema_diff/directory_compare.py b/web/pgadmin/tools/schema_diff/directory_compare.py index 569b5b881..43905ef2f 100644 --- a/web/pgadmin/tools/schema_diff/directory_compare.py +++ b/web/pgadmin/tools/schema_diff/directory_compare.py @@ -627,7 +627,6 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference=None): for index in range(len(source_dict[key])): source = copy.deepcopy(source_dict[key][index]) if isinstance(source, list): - # TODO pass elif isinstance(source, dict): # Check the above keys are exist in the dictionary diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 85216a81c..3fbbe84f4 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -1860,18 +1860,17 @@ def save_file(): last_storage = Preferences.module('file_manager').preference( 'last_storage').get() if last_storage != MY_STORAGE: - selectedDirList = [sdir for sdir in SHARED_STORAGE if - sdir['name'] == last_storage] - selectedDir = selectedDirList[0] if len( - selectedDirList) == 1 else None + selected_dir_list = [sdir for sdir in SHARED_STORAGE if + sdir['name'] == last_storage] + selected_dir = selected_dir_list[0] if len( + selected_dir_list) == 1 else None - if selectedDir: - if selectedDir['restricted_access'] and \ - not current_user.has_role("Administrator"): - return make_json_response(success=0, - errormsg=ACCESS_DENIED_MESSAGE, - info='ACCESS_DENIED', - status=403) + if selected_dir and selected_dir['restricted_access'] and \ + not current_user.has_role("Administrator"): + return make_json_response(success=0, + errormsg=ACCESS_DENIED_MESSAGE, + info='ACCESS_DENIED', + status=403) storage_manager_path = get_storage_directory( shared_storage=last_storage) else: diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx index d5b3985fa..36fd8450c 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx @@ -632,7 +632,7 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) { > {gettext('Manage macros')} - {queryToolCtx.params?.macros?.map((m, i)=>{ + {queryToolCtx.params?.macros?.map((m)=>{ return ( executeMacro(m)} key={i}> + }} onClick={()=>executeMacro(m)} key={m.name}> {m.name} ); diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/Notifications.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/Notifications.jsx index 41bdae625..5854c52ae 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/Notifications.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/Notifications.jsx @@ -45,8 +45,8 @@ export function Notifications() {
    - {notices.map((notice, i)=>{ - return + {notices.map((notice)=>{ + return diff --git a/web/pgadmin/tools/sqleditor/utils/apply_explain_plan_wrapper.py b/web/pgadmin/tools/sqleditor/utils/apply_explain_plan_wrapper.py index 7fd410009..c8c3cc44f 100644 --- a/web/pgadmin/tools/sqleditor/utils/apply_explain_plan_wrapper.py +++ b/web/pgadmin/tools/sqleditor/utils/apply_explain_plan_wrapper.py @@ -17,8 +17,6 @@ def apply_explain_plan_wrapper_if_needed(manager, sql): if 'explain_plan' in sql and sql['explain_plan']: explain_plan = sql['explain_plan'] ver = manager.version if manager.version is not None else 0 - server_type = \ - manager.server_type if manager.server_type is not None else 'pg' template_path = compile_template_name( 'sqleditor/sql', 'explain_plan.sql', diff --git a/web/pgadmin/utils/__init__.py b/web/pgadmin/utils/__init__.py index b4ac6ed17..41dcf6a0e 100644 --- a/web/pgadmin/utils/__init__.py +++ b/web/pgadmin/utils/__init__.py @@ -267,7 +267,8 @@ def filename_with_file_manager_path(_file, create_file=False, """ Args: file: File name returned from client file manager - create_file: Set flag to False when file creation doesn't required + create_file: Set flag to False when file creation doesn't require + skip_permission_check: Returns: Filename to use for backup with full path taken from preference """ @@ -275,22 +276,21 @@ def filename_with_file_manager_path(_file, create_file=False, try: last_storage = Preferences.module('file_manager').preference( 'last_storage').get() - except Exception as e: + except Exception: last_storage = MY_STORAGE if last_storage != MY_STORAGE: - selDirList = [sdir for sdir in current_app.config['SHARED_STORAGE'] - if sdir['name'] == last_storage] - selectedDir = selDirList[0] if len( - selDirList) == 1 else None + sel_dir_list = [sdir for sdir in current_app.config['SHARED_STORAGE'] + if sdir['name'] == last_storage] + selected_dir = sel_dir_list[0] if len( + sel_dir_list) == 1 else None - if selectedDir: - if selectedDir['restricted_access'] and \ - not current_user.has_role("Administrator"): - return make_json_response(success=0, - errormsg=ACCESS_DENIED_MESSAGE, - info='ACCESS_DENIED', - status=403) + if selected_dir and selected_dir['restricted_access'] and \ + not current_user.has_role("Administrator"): + return make_json_response(success=0, + errormsg=ACCESS_DENIED_MESSAGE, + info='ACCESS_DENIED', + status=403) storage_dir = get_storage_directory( shared_storage=last_storage) else: diff --git a/web/pgadmin/utils/driver/psycopg3/connection.py b/web/pgadmin/utils/driver/psycopg3/connection.py index 9b8905178..9e0a225f5 100644 --- a/web/pgadmin/utils/driver/psycopg3/connection.py +++ b/web/pgadmin/utils/driver/psycopg3/connection.py @@ -800,14 +800,12 @@ WHERE db.datname = current_database()""") query = query.encode(self.python_encoding) cur.execute(query, params) - def execute_on_server_as_csv(self, formatted_exception_msg=False, - records=2000): + def execute_on_server_as_csv(self, records=2000): """ To fetch query result and generate CSV output Args: params: Additional parameters - formatted_exception_msg: For exception records: Number of initial records Returns: Generator response @@ -1011,7 +1009,7 @@ WHERE db.datname = current_database()""") # If multiple queries are run, make sure to reach # the last query result while cur.nextset(): - pass + pass # This loop is empty self.row_count = cur.get_rowcount() if cur.get_rowcount() > 0: @@ -1444,10 +1442,10 @@ Failed to reset the connection to the server due to following error: asyncio.run(_close_conn(self.conn)) def _wait(self, conn): - pass + pass # This function is empty def _wait_timeout(self, conn): - pass + pass # This function is empty def poll(self, formatted_exception_msg=False, no_result=False): cur = self.__async_cursor @@ -1474,9 +1472,8 @@ Failed to reset the connection to the server due to following error: while more_result: if not self.conn.pgconn.is_busy(): if cur.description is not None: - for desc in cur.ordered_description(): - self.column_info = [desc.to_dict() for - desc in cur.ordered_description()] + self.column_info = [desc.to_dict() for + desc in cur.ordered_description()] pos = 0 if self.column_info: diff --git a/web/pgadmin/utils/driver/psycopg3/server_manager.py b/web/pgadmin/utils/driver/psycopg3/server_manager.py index 80b5756cd..40dccf87d 100644 --- a/web/pgadmin/utils/driver/psycopg3/server_manager.py +++ b/web/pgadmin/utils/driver/psycopg3/server_manager.py @@ -389,7 +389,7 @@ WHERE db.oid = {0}""".format(did)) conn = self.connections[conn_id] # only try to reconnect if connection was connected previously # and auto_reconnect is true. - wasConnected = conn.wasConnected + was_connected = conn.wasConnected auto_reconnect = conn.auto_reconnect if conn.wasConnected and conn.auto_reconnect: try: @@ -409,7 +409,7 @@ WHERE db.oid = {0}""".format(did)) except CryptKeyMissing: # maintain the status as this will help to restore once # the key is available - conn.wasConnected = wasConnected + conn.wasConnected = was_connected conn.auto_reconnect = auto_reconnect except Exception as e: self.connections.pop(conn_id) diff --git a/web/pgadmin/utils/paths.py b/web/pgadmin/utils/paths.py index 3a5ad7ece..98e0f4814 100644 --- a/web/pgadmin/utils/paths.py +++ b/web/pgadmin/utils/paths.py @@ -17,6 +17,8 @@ from werkzeug.exceptions import InternalServerError from pgadmin.utils.constants import MY_STORAGE from pgadmin.model import User +PGADMIN_PATH = '~/.pgadmin/' + def preprocess_username(un): ret_un = un @@ -40,18 +42,18 @@ def get_storage_directory(user=current_user, shared_storage=''): is_shared_storage = False if shared_storage != MY_STORAGE and shared_storage: is_shared_storage = True - selectedDir = [sdir for sdir in config.SHARED_STORAGE if - sdir['name'] == shared_storage] + selected_dir = [sdir for sdir in config.SHARED_STORAGE if + sdir['name'] == shared_storage] storage_dir = None - if len(selectedDir) > 0: - the_dir = selectedDir[0]['path'] + if len(selected_dir) > 0: + the_dir = selected_dir[0]['path'] storage_dir = the_dir else: storage_dir = getattr( config, 'STORAGE_DIR', os.path.join( os.path.realpath( - os.path.expanduser('~/.pgadmin/') + os.path.expanduser(PGADMIN_PATH) ), 'storage' ) ) @@ -109,7 +111,7 @@ def init_app(): config, 'STORAGE_DIR', os.path.join( os.path.realpath( - os.path.expanduser('~/.pgadmin/') + os.path.expanduser(PGADMIN_PATH) ), 'storage' ) ) @@ -159,7 +161,7 @@ def create_users_storage_directory(): config, 'STORAGE_DIR', os.path.join( os.path.realpath( - os.path.expanduser('~/.pgadmin/') + os.path.expanduser(PGADMIN_PATH) ), 'storage' ) ) diff --git a/web/regression/feature_tests/query_tool_tests.py b/web/regression/feature_tests/query_tool_tests.py index ace090a39..cdb1ec73f 100644 --- a/web/regression/feature_tests/query_tool_tests.py +++ b/web/regression/feature_tests/query_tool_tests.py @@ -45,7 +45,6 @@ class QueryToolFeatureTest(BaseFeatureTest): def runTest(self): self._reset_options() - skip_warning = "Skipped." # on demand result set on scrolling. print("\nOn demand query result... ", file=sys.stderr, end="")
    {notice.recorded_time} {notice.channel} {notice.pid}