mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
fix selected query (fixes #12429)
This commit is contained in:
parent
1eac259833
commit
b1dd253fc5
@ -111,7 +111,8 @@ class DlgSqlWindow(QDialog, Ui_Dialog):
|
||||
self.presetCombo.setCurrentIndex(-1)
|
||||
|
||||
def storePreset(self):
|
||||
query = self.editSql.text()
|
||||
query = self._getSqlQuery()
|
||||
if query == "": return
|
||||
name = self.presetName.text()
|
||||
QgsProject.instance().writeEntry('DBManager', 'savedQueries/q' + str(name.__hash__()) + '/name', name)
|
||||
QgsProject.instance().writeEntry('DBManager', 'savedQueries/q' + str(name.__hash__()) + '/query', query)
|
||||
@ -150,12 +151,8 @@ class DlgSqlWindow(QDialog, Ui_Dialog):
|
||||
|
||||
def executeSql(self):
|
||||
|
||||
sql = self.editSql.selectedText()
|
||||
if len(sql) == 0:
|
||||
sql = self.editSql.text()
|
||||
|
||||
if sql == "":
|
||||
return
|
||||
sql = self._getSqlQuery()
|
||||
if sql == "": return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
|
||||
@ -198,9 +195,8 @@ class DlgSqlWindow(QDialog, Ui_Dialog):
|
||||
else:
|
||||
geomFieldName = None
|
||||
|
||||
query = self.editSql.text()
|
||||
if query == "":
|
||||
return
|
||||
query = self._getSqlQuery()
|
||||
if query == "": return
|
||||
|
||||
# remove a trailing ';' from query if present
|
||||
if query.strip().endswith(';'):
|
||||
@ -235,7 +231,7 @@ class DlgSqlWindow(QDialog, Ui_Dialog):
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def fillColumnCombos(self):
|
||||
query = self.editSql.text()
|
||||
query = self._getSqlQuery()
|
||||
if query == "": return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
@ -351,4 +347,9 @@ class DlgSqlWindow(QDialog, Ui_Dialog):
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
|
||||
def _getSqlQuery(self):
|
||||
sql = self.editSql.selectedText()
|
||||
if len(sql) == 0:
|
||||
sql = self.editSql.text()
|
||||
return sql
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user