Skip to content
Permalink
Browse files

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

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

def executeSql(self):

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

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

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

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

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

@@ -588,16 +588,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 f37d48f

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