Skip to content


[db_manager] Fix #14796 - Quote values depending on data type in quer…
Browse files Browse the repository at this point in the history
…y builder
  • Loading branch information
arnaud-morvan authored and slarosa committed May 29, 2016
1 parent 87121d6 commit 8e5b28f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion python/plugins/db_manager/db_plugins/
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ def columnCount(self, parent=None):
return len(self._header)

def data(self, index, role):
if role != Qt.DisplayRole and role != Qt.FontRole:
if role not in [Qt.DisplayRole,
return None

val = self.getData(index.row(), index.column())

if role == Qt.EditRole:
return val

if role == Qt.FontRole: # draw NULL in italic
if val is not None:
return None
Expand Down
17 changes: 12 additions & 5 deletions python/plugins/db_manager/
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Query builder dialog, based on the QSpatialite plugin (GPLv2+) by Romain Riviere

from qgis.PyQt.QtCore import QObject, QEvent
from qgis.PyQt.QtCore import Qt, QObject, QEvent
from qgis.PyQt.QtWidgets import QDialog, QMessageBox, QTextEdit

from .ui.ui_DlgQueryBuilder import Ui_DbManagerQueryBuilderDlg as Ui_Dialog
Expand Down Expand Up @@ -287,10 +287,17 @@ def list_values(self):

def query_item(self, index):
queryWord =
queryWord = ' "%s"' % queryWord
if queryWord != '':
value =

if value is None:
queryWord = u'NULL'
elif isinstance(value, (int, float)):
queryWord = unicode(value)
queryWord = self.db.connector.quoteString(value)

if queryWord.strip() != '':
self.ui.where.insertPlainText(u' ' + queryWord)

def use_rtree(self):
Expand Down

0 comments on commit 8e5b28f

Please sign in to comment.