Skip to content
Permalink
Browse files

fix selected query

  • Loading branch information
Gustry committed Apr 21, 2015
1 parent 4bc7402 commit fd817ec3ef16e5b1073b869a589b455492999bd0
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 fd817ec

Please sign in to comment.
You can’t perform that action at this time.