Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[db_manager] Fix #14796 - Quote values depending on data type in quer…
- Loading branch information
|
@@ -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, |
|
|
Qt.EditRole, |
|
|
Qt.FontRole]: |
|
|
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): |
|
|
self.ui.values.setModel(model) |
|
|
|
|
|
def query_item(self, index): |
|
|
queryWord = index.data() |
|
|
queryWord = ' "%s"' % queryWord |
|
|
if queryWord != '': |
|
|
self.ui.where.insertPlainText(queryWord) |
|
|
value = index.data(Qt.EditRole) |
|
|
|
|
|
if value is None: |
|
|
queryWord = u'NULL' |
|
|
elif isinstance(value, (int, float)): |
|
|
queryWord = unicode(value) |
|
|
else: |
|
|
queryWord = self.db.connector.quoteString(value) |
|
|
|
|
|
if queryWord.strip() != '': |
|
|
self.ui.where.insertPlainText(u' ' + queryWord) |
|
|
self.ui.where.setFocus() |
|
|
|
|
|
def use_rtree(self): |
|
|