Skip to content
Permalink
Browse files

keep comments when save as preset or file, remove lines starting by "…

…--" in DBManager
  • Loading branch information
Gustry authored and nyalldawson committed Feb 16, 2019
1 parent 2ed6c67 commit 06f9be1ca177c4df68ae1906e02a9d11f212c690
Showing with 16 additions and 5 deletions.
  1. +16 −5 python/plugins/db_manager/dlg_sql_window.py
@@ -313,7 +313,7 @@ def executeSqlCompleted(self):

def executeSql(self):

sql = self._getSqlQuery()
sql = self._getExecutableSqlQuery()
if sql == "":
return

@@ -355,7 +355,7 @@ def _getSqlLayer(self, _filter):
else:
geomFieldName = None

query = self._getSqlQuery()
query = self._getSqlExecutableQuery()
if query == "":
return None

@@ -400,7 +400,7 @@ def loadSqlLayer(self):
QgsProject.instance().addMapLayers([layer], True)

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

@@ -555,16 +555,27 @@ def createView(self):
name, ok = QInputDialog.getText(None, self.tr("View Name"), self.tr("View name"))
if ok:
try:
self.db.connector.createSpatialView(name, self._getSqlQuery())
self.db.connector.createSpatialView(name, self._getExecutableSqlQuery())
except BaseError as e:
DlgDbError.showError(e, self)

def _getSqlQuery(self):
sql = self.editSql.selectedText()
if len(sql) == 0:
sql = self.editSql.text().replace('\n', ' ').strip()
sql = self.editSql.text()
return sql

def _getExecutableSqlQuery(self):
sql = self._getSqlQuery()

# Clean it up!
lines = []
for line in sql.split('\n'):
if not line.strip().startswith('--'):
lines.append(line)
sql = ' '.join(lines)
return sql.strip()

def uniqueChanged(self):
# when an item is (un)checked, simply trigger an update of the combobox text
self.uniqueTextChanged(None)

0 comments on commit 06f9be1

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