diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js
index ba6b038ca..c3487b1bd 100644
--- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js
+++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js
@@ -59,6 +59,7 @@ export const QUERY_TOOL_EVENTS = {
EDITOR_FIND_REPLACE: 'EDITOR_FIND_REPLACE',
EDITOR_EXEC_CMD: 'EDITOR_EXEC_CMD',
EDITOR_SET_SQL: 'EDITOR_SET_SQL',
+ EDITOR_TOGGLE_CASE: 'EDITOR_TOGGLE_CASE',
COPY_TO_EDITOR: 'COPY_TO_EDITOR',
WARN_SAVE_DATA_CLOSE: 'WARN_SAVE_DATA_CLOSE',
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 19271e16b..217c5645b 100644
--- a/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx
+++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx
@@ -335,6 +335,9 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
const formatSQL=()=>{
eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_FORMAT_SQL);
};
+ const toggleCase=()=>{
+ eventBus.fireEvent(QUERY_TOOL_EVENTS.EDITOR_TOGGLE_CASE);
+ };
const clearQuery=()=>{
confirmDiscard(()=>{
eventBus.fireEvent(QUERY_TOOL_EVENTS.EDITOR_SET_SQL, '');
@@ -418,6 +421,12 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
callback: ()=>{formatSQL();}
}
},
+ {
+ shortcut: queryToolPref.toggle_case,
+ options: {
+ callback: ()=>{toggleCase();}
+ }
+ },
{
shortcut: queryToolPref.clear_query,
options: {
@@ -565,6 +574,8 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
onClick={()=>{eventBus.fireEvent(QUERY_TOOL_EVENTS.EDITOR_EXEC_CMD, 'indentLess');}}>{gettext('Unindent Selection')}
{eventBus.fireEvent(QUERY_TOOL_EVENTS.EDITOR_EXEC_CMD, 'toggleComment');}}>{gettext('Toggle Comment')}
+ {gettext('Toggle Case Of Selected Text')}
{gettext('Clear Query')}
diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx
index 808057d4e..b45a46761 100644
--- a/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx
+++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx
@@ -377,6 +377,16 @@ export default function Query() {
}
}).catch(()=>{/* failure should be ignored */});
});
+ eventBus.registerListener(QUERY_TOOL_EVENTS.EDITOR_TOGGLE_CASE, ()=>{
+ let selectedText = editor.current?.getSelection();
+ if (!selectedText) return;
+
+ if (selectedText === selectedText.toUpperCase()) {
+ editor.current.replaceSelection(selectedText.toLowerCase());
+ } else {
+ editor.current.replaceSelection(selectedText.toUpperCase());
+ }
+ });
editor.current.focus();
}, []);