Skip to content
Browse files

[db_manager] Fix #14796 - Quote values depending on data type in quer…

…y builder
  • Loading branch information
arnaud-morvan authored and slarosa committed May 20, 2016
1 parent 87121d6 commit 8e5b28f3bb5d7fb46b54c69176ec4143268ea977
@@ -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
@@ -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
@@ -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):

0 comments on commit 8e5b28f

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