Skip to content
Permalink
Browse files
fix selected query (fixes #12429)
  • Loading branch information
Gustry authored and brushtyler committed May 26, 2015
1 parent 1eac259 commit b1dd253fc51df32f11c0d0ae7d9a2ab373582ba7
Showing with 13 additions and 12 deletions.
  1. +13 −12 python/plugins/db_manager/dlg_sql_window.py
@@ -111,7 +111,8 @@ def updatePresetsCombobox(self):
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 @@ def clearSql(self):

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 @@ def loadSqlLayer(self):
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 @@ def loadSqlLayer(self):
QApplication.restoreOverrideCursor()

def fillColumnCombos(self):
query = self.editSql.text()
query = self._getSqlQuery()
if query == "": return

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
@@ -351,4 +347,9 @@ def createView( self ):
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

0 comments on commit b1dd253

Please sign in to comment.