From 72644d873c3bcd7d14da0f61468a1a6a5c953f26 Mon Sep 17 00:00:00 2001 From: raymondnijssen Date: Tue, 7 Nov 2023 14:19:37 +0100 Subject: [PATCH] Only run selected SQL code --- src/gui/qgsqueryresultwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/qgsqueryresultwidget.cpp b/src/gui/qgsqueryresultwidget.cpp index 138e24c1dab4..bcaec9468ba1 100644 --- a/src/gui/qgsqueryresultwidget.cpp +++ b/src/gui/qgsqueryresultwidget.cpp @@ -172,7 +172,11 @@ void QgsQueryResultWidget::executeQuery() cancelRunningQuery(); if ( mConnection ) { - const QString sql { mSqlEditor->text( ) }; + QString sql { mSqlEditor->text() }; + if ( mSqlEditor->hasSelectedText() ) + { + sql = mSqlEditor->selectedText(); + } bool ok = false; mCurrentHistoryEntryId = QgsGui::historyProviderRegistry()->addEntry( QStringLiteral( "dbquery" ),