Skip to content
Permalink
Browse files
Merge pull request #2000 from Gustry/fix-selected-query-backport
[db_manager] backport 2.8.2 fix #12429 run only the selected query
  • Loading branch information
brushtyler committed May 26, 2015
2 parents 5d5229e + fd817ec commit acd003e04b76944f7973e3a521db3ee7a67f14cc
Showing with 13 additions and 11 deletions.
  1. +13 −11 python/plugins/db_manager/dlg_sql_window.py
@@ -101,7 +101,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 )
@@ -140,12 +141,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))

@@ -184,9 +181,8 @@ def loadSqlLayer(self):
QMessageBox.warning(self, self.tr( "DB Manager" ), self.tr( "You must fill the required fields: \ngeometry column - column with unique integer values" ) )
return

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

# remove a trailing ';' from query if present
if query.strip().endswith(';'):
@@ -219,7 +215,7 @@ def loadSqlLayer(self):
QApplication.restoreOverrideCursor()

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

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
@@ -318,3 +314,9 @@ def initCompleter(self):

api.prepare()
self.editSql.lexer().setAPIs(api)

def _getSqlQuery(self):
sql = self.editSql.selectedText()
if len(sql) == 0:
sql = self.editSql.text()
return sql

0 comments on commit acd003e

Please sign in to comment.